Skip to content

Commit 9bf24c8

Browse files
committed
2 parents 96e471d + 37228c9 commit 9bf24c8

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,112 @@ var v = (a , b) =>
7070

7171
v(2,3);
7272

73+
74+
# Day 3 - Global Object
75+
In NodeJs Global Object, Object which we can be access by any modules.
76+
77+
We do not need to include these objects in our application, rather we can use them directly
78+
79+
// __dirname : it use to check the directive name.
80+
console.log(__dirname)
81+
82+
//__filename : it use to check the file name.
83+
console.log(__filename)
84+
85+
__// Console : it view the data in terimnal.
86+
console.log("Satya")
87+
88+
__// Require : include any out side module in page.
89+
var requireTest = require("./requiretest");
90+
console.log(requireTest.abc);
91+
Creating your own module.
92+
93+
Requiretest.js
94+
========================================================
95+
// Arrow function is based on arrow function keys/
96+
97+
const name = "Satya Rathore";
98+
var v1 = () => console.log("this is arrow function");
99+
v1();
100+
101+
module.exports.abc = name;
102+
========================================================
103+
104+
Some other global object aree
105+
//buffer
106+
//module
107+
//Reports
108+
//Process
109+
110+
111+
# Day 11 - Express App Generator
112+
113+
1. Expression App generator is not directly working for me to Install from Terminal of Visual Studio Code.
114+
115+
2. I installed the nodeJsexpression from node.js commond prompt.
116+
117+
3. For more details about express applocation generation you can see the below URL.
118+
https://expressjs.com/en/starter/generator.html
119+
120+
4. It provide the step by step way to do that.
121+
122+
5. After installed it successfully, used below command to get the application template.
123+
>express E:\node_tutorial\day11-ExpressAppGenerator
124+
125+
6. Move to >cd E:\node_tutorial\day11-ExpressAppGenerator
126+
127+
7. Now run the application as below.
128+
129+
8. Now get the template of pug instade of creating blank and default template.
130+
>express --view=ejs E:\node_tutorial\day11-ExpressAppGenerator
131+
132+
9. Than install all the packages
133+
> npm install
134+
135+
10. Now we run the application by.
136+
> SET DEBUG=day11-expressappgenerator:* & npm start
137+
138+
11. It create all the structure of application which is required.
139+
a) Public -- Whch is work like assets folder having image, Script and style locations.
140+
b) Routes -- It contain the defination of all rotings.
141+
c) View -- All application view.
142+
143+
12. To add any view or update the any view you need to check the view file.
144+
145+
like index.ejs
146+
=========================
147+
148+
<!DOCTYPE html>
149+
<html>
150+
<head>
151+
<title><%= title %></title>
152+
<link rel='stylesheet' href='/stylesheets/style.css' />
153+
</head>
154+
<body>
155+
<h1><%= title %></h1>
156+
<p><%= message %></p>
157+
</body>
158+
</html>
159+
====================
160+
161+
In above you can see the title and Message is binding dynamically and it is passing from the routes file.
162+
Routes/Index.js
163+
===========================
164+
var express = require('express');
165+
var router = express.Router();
166+
167+
/* GET home page. */
168+
router.get('/', function(req, res, next) {
169+
res.render('index', { title: 'Satya', message : 'Welcome to NodeJs exress' });
170+
});
171+
172+
module.exports = router;
173+
174+
=============================
175+
176+
Here you can see the Title is satya and Message is 'Welcome to NodeJs exress'
177+
you can see it in browser as.
178+
<img src="">
179+
180+
181+

0 commit comments

Comments
 (0)