Unit1 RiteshKumarSingh
Unit1 RiteshKumarSingh
WEB DEVELOPMENT
USING MERN STACK
Unit: I
Introduction to Nodejs
Amarish Jaysawal
Course Details (Asst. Professor)
(B. Tech. 6th Sem)
CSE Department
28/05/2025
Evaluation Scheme
28/05/2025 4
Syllabus
28/05/2025 5
Syllabus
28/05/2025 6
Syllabus
28/05/2025 7
Syllabus
28/05/2025 8
Branch Wise Application
28/05/2025 9
Course Objective
Study how to design and build static as well as dynamic webpages and
interactive web applications
Students examine advanced topics like ReactJS, NodeJS, MongoDB for web
applications.
Also examine Express framework for interactive web applications that use rich
user interfaces .
28/05/2025 10
Course Outcomes (COs)
CO2 : Demonstrate Express framework to design and implement dynamic web pages .
CO3 : Apply the knowledge of Javascript that are vital in understanding ReactJS.
CO4 : Analyze build and develop single page application using client-side programming.
CO5 : Understand the impact of web designing by database connectivity with Mongodb
28/05/2025 11
Program Outcomes (POs)
PO8 : Ethics
PO10 : Communication
CO.K PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
CO1 2 2 2 3 3 - - - - - - -
CO2 3 2 3 2 3 - - - - - - -
CO3 3 2 3 2 3 - - - - - - -
CO4 3 2 3 2 3 - - - - - - -
CO5 3 2 3 3 3 - - - - - - -
28/05/2025 14
Program Specific Outcomes(PSOs)
Program Specific
S. No. PSO Description
Outcomes (PSO)
Understand to shows relationships and
interactions between classes or objects of a
1 PSO1 pattern.
28/05/2025 15
COs - PSOs Mapping
CO1 3 - - -
CO2 3 3 - -
CO3 3 3 - -
CO4 3 3 - -
CO5 3 3 - -
28/05/2025 16
Program Educational Objectives (PEOs)
Program Educational
PEOs Description
Objectives (PEOs)
To have an excellent scientific and engineering breadth so as to comprehend,
PEOs analyze, design and provide sustainable solutions for real-life problems using state-
of-the-art technologies.
To have life-long learning for up-skilling and re-skilling for successful professional
PEOs career as engineer, scientist, entrepreneur and bureaucrat for betterment of society.
28/05/2025 17
Result Analysis(Department Result & Subject Result & Individual result
Mr. Amarish
ACSE0614
Jaysawal
28/05/2025 18
Pattern of Online External Exam Question Paper (100 marks)
28/05/2025 19
Pattern of Online External Exam Question Paper (100 marks)
28/05/2025 20
Pattern of Online External Exam Question Paper (100 marks)
28/05/2025 21
Pattern of Online External Exam Question Paper (100 marks)
28/05/2025 22
Pattern of Online External Exam Question Paper (100 marks)
28/05/2025 23
Prerequisite / Recap
terminology.
28/05/2025 24
Brief Introduction about the Subject with videos
• https://youtu.be/BLl32FvcdVM
• https://youtu.be/v9ejT8FO-7I?list=PLrhzvIcii6GNjpARdnO4ueTUAVR9eMBpc
28/05/2025 25
Unit I Content
28/05/2025 27
Topic Objective
Node Js is built on Google Chrome’s V8 engine, and for this reason its execution time is
very fast and it runs very quickly.
There are more than 50,000 bundles available in the Node Package Manager and for
that reason developers can import any of the packages any time according to their
needed functionality for which a lot of time is saved.
As Node Js do not need to wait for an API to return data , so for building
real time and data intensive web applications, it is very useful. It is totally
asynchronous in nature that means it is totally non-blocking.
The loading time for an audio or video is reduced by NodeJs because there
is better synchronization of the code between the client and server for
having the same code base.
As NodeJs is open-source and it is nothing but a JavaScript framework , so
for the developers who are already used to JavaScript, for them starting
developing their projects with NodeJs is very easy.
Features of Node Js
Asynchronous in Nature and Event driven: The servers made with
the NodeJs never waits for the from an API. Without waiting for
the data from the API, it directly moves to the next API. So all the
APIs of NodeJS are totally non-blocking in nature. In order to
receive and track all the responses of the previous API requests, it
follows an event driven mechanism. Hence we can say that all the
NodeJs API are non-blocking in nature.
Compatibility on the cross platforms: Different types of systems like Windows, UNIX,
LINUX, MacOS and other mobile devices can use NodeJs.
Fast Data Streaming: The processing time of the data that have been transmitted to
different streams takes a long time. Whereas for processing the data, NodeJs takes a very
short amount of time and it does it at a very fast rate. NodeJs saves a lot of time because
the files are processed and uploaded simultaneously by NodeJs. So as a result, the overall
speed of data and video streaming is improved by NodeJs.
No Buffering : The data is never buffered in NodeJs application.
Read Files
The fs.readFile() method is used to read files on your
computer.
Assume we have the following HTML file (located in the same
folder as Node.js):
demofile1.html
<html>
<body>
<h1>My Header</h1>
<p>My paragraph.</p>
</body>
</html>
Ritesh Kumar Singh WEB
28/05/2025 DEVELOPMENT USING MEAN STACK 47
Unit I
Node Js Modules
Create a Node.js file that reads the HTML file, and return
the content:
Example
var http = require('http');
var fs = require('fs');
http.createServer(function (req, res) {
fs.readFile('demofile1.html', function(err, data) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(data);
return res.end();
});
}).listen(8080);
Ritesh Kumar Singh WEB
28/05/2025 DEVELOPMENT USING MEAN STACK 48
Unit I
Node Js Modules
Ceate Files
The File System module has The fs.appendFile() method appends specified content to a
methods for creating new file. If the file does not exist, the file will be created:
files: Example
•fs.appendFile() Create a new file using the appendFile() method:
var fs = require('fs');
•fs.open()
•fs.writeFile() fs.appendFile('mynewfile1.txt', 'Hello
content!', function (err) {
if (err) throw err;
console.log('Saved!');
});
Run example »
[
{
"name": "John",
"age": 21,
"language": ["JavaScript", "PHP", "Python"]
},
{
"name": "Smith",
"age": 25,
"language": ["PHP", "Go", "JavaScript"]
}
]
const fs = require("fs");
// Converting to JSON
const users = JSON.parse(data);
Output:
Example 2: Code for reading a file asynchronously (non-blocking code) in Node.js. Create a text
file inputfile1.txt with the following content.
Hello Programmer!!! Learn NodeJS with GeeksforGeeks
// Write a JavaScript code
var fs = require("fs");
POST: The POST verb is most often utilized to create new resources. In particular, it’s
used to create subordinate resources. That is, subordinate to some other (e.g. parent)
resource. On successful creation, return HTTP status 201, returning a Location header with
a link to the newly-created resource with the 201 HTTP status.
client.close();
});
});
});
});
});
To resolve this issue we need to get rid of the callback functions whilst
nesting. This is where Promises come into the picture. A Promise in Node
means an action which will either be completed or rejected. In case of
completion, the promise is kept and otherwise, the promise is broken. So as the
word suggests either the promise is kept or it is broken. And unlike callbacks,
promises can be chained.
Nested Promises: Often you will encounter situations where you need to
make use of nested Promises. Nested promises begin with a .then() and in
each of the .then() we have a return statement. After the return
statement, .then() follows in the same manner. Following example shows
the worst case scenario wherein multiple .then() methods are used in order
to declare nested promises (which are dependent on each other for their own
execution).
Template engines are used when you want to rapidly build web
applications that are split into different components. Templates also enable
fast rendering of the server-side data that needs to be passed to the
application.
Template engines are mostly used for server-side applications that are run
on only one server and are not built as APIs. The popular ones include Ejs,
Jade, Pug, Mustache, HandlebarsJS, Jinja2, and Blade.
Q 4 -) To include the HTTP server in the node module, what function do we use?
A get()
B require()
C createServer()
D None of the above
Q5-) To include the HTTP server in the node module, what function do we use?
A Export
B Expose
C Require
D None of the above
1. What is Node.Js.
2. What is the various module present in Node.Js.
3. Describe the steps to install Node.Js in windows.
4. Elaborate promises in Node.Js.
5. Discuss Callback function in Node.Js.
• https://youtu.be/rI4kdGLaUiQ?list=PL6n9fhu94yhUbctIoxoVTrklN3LMwTCmd
• https://youtu.be/v9ejT8FO-7I?list=PLrhzvIcii6GNjpARdnO4ueTUAVR9eMBpc
• https://youtu.be/VGLjQuEQgkI?list=PLt4nG7RVVk1h9lxOYSOGI9pcP3I5oblbx