Unit - 3 - Web Development With MERN Stack Using DevOps
Unit - 3 - Web Development With MERN Stack Using DevOps
Unit - 3 - Web Development With MERN Stack Using DevOps
Unit: 3
Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Faculty Introduction
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Evaluation Scheme
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Google Material UI, AppBar, Material UI's Syllabus
Toolbar, NavBar, Material
UI Buttons, SQL and Complex Transactions, Dynamic S chema,
create Index (), get Indexes
UNIT-II: () & drop
Connecting Index
React with(), Statement-based
mongo dB vs.
Binary Replication, Auto-Sharding and Integrated Caching, Load
balancing, Aggregation, scalability.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Syllabus
Introduction, Environment Setup, Serving static resources, Template
engine with vash and jade, Connecting Node.js to Database,
Mongoose Module,Node
UNIT-III: Creating Rest APIs, Express Framework,
js & Express
M VC Pattern, Routing,
Framework Cookies and Sessions, HTTP Interaction,
User Authentication.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Sunday, May 19, 2024
DevOps Principles, DevOps Lifecycle, DevOps Tools, Benefits of
Syllabus
DevOps, S D LC models, Lean, ITIL and, Agile Methodology, Agile vs
DevOps, Process flow of Scrum Methodologies, Project planning,
scrum testing, sprint Planning
UNIT-IV: EVOLUTION and Release management,
OF DEVOPS js Continuous
Integration and Delivery pipeline.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
GitHub, Introduction to Git, Version control,Syllabus
Jenkins Introduction,
Creating Job in Jenkins, Adding plugin in Jenkins, Creating Job with
Maven & Git, Integration of j Unit testing, Sonar, Dockers,
U N I T- V: C I / C D C o n c e p t s ( G i t H u b ,
Containers Image How to run, pull and push containers, Container
Jenkins, Sonar)
lifecycle, Introduction to Kubernetes.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with D
evOps Unit III
PO6:::Conduct
PO5
PO4 The engineer
Engineering
PO1
PO2
PO3 Problem
Engineering andwill
Graduates
Design/Development
Modern Analysis
toolKnowledge
usage
Investigations society
of ofbe Program
able to:
solutions
complex problems Outcomes (POs)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with D
evOps Unit III
PO12: Individual
PO8
PO9
PO10
PO11 :Project
Life-long
Engineering
PO7 Ethics
:Environmentlearning
Graduates
Communication
andand willand
teamwork Program
be able
sustainability
management to:
finance Outcomes (POs)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with D
evOps Unit III
COs - POs Mapping
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 - - - - - - -
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Program Specific Outcomes(PSOs)
Program Specific
S. No. PSO Description
Outcomes (PSO)
Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
COs - PSOs Mapping
CO1 3 - - -
CO2 3 3 - -
CO3 3 3 - -
CO4 3 3 - -
CO5 3 3 - -
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
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.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Result Analysis(Department Result & Subject Result & Individual result
Srishti Dikshit Web Development using MERN Stack with DevOps Unit
Sunday, May 19, 2024 III
Pattern of Online External Exam Question Paper (100 marks)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Pattern of Online External Exam Question Paper (100 marks)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Pattern of Online External Exam Question Paper (100 marks)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Pattern of Online External Exam Question Paper (100 marks)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Pattern of Online External Exam Question Paper (100 marks)
Srishti Dikshit Web Development using MERN Stack with DevOps Unit
Sunday, May 19, 2024 III
Prerequisite / Recap
Srishti Dikshit Web Development using MERN Stack with DevOps Unit
Sunday, May 19, 2024 III
Brief Introduction about the Subject with videos
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Unit III Content
• Introduction, Environment Setup,
• Serving static resources, template engine with vash and jade,
• Connecting Node.js to Database,
• Mongoose Module,
• Creating Rest APIs,
• Express Framework & MVC Pattern,
• Routing,
• Cookies and Sessions,
• HTTP Interaction,
• User Authentication
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Unit III Objective
In Unit III, students will:
• Embark on a comprehensive exploration of foundational concepts in Node.js and web application development.
• Through a dynamic progression of topics, students will master the introductory principles of Node.js, establish
efficient development environments, and harness the power of the Serving static resources, template engine with
vash and jade.
• They will grasp the significance of streams and buffers in data manipulation, learn the art of seamlessly
connecting Node.js applications to databases using the Mongoose module, and gain proficiency in creating
RESTful APIs through the expressive Express framework.
• Furthermore, students will unlock the Model-View-Controller (MVC) pattern for organized code structuring,
navigate the realm of routing to ensure seamless navigation, and delve into the vital realm of cookies, sessions,
HTTP interaction, and user authentication, fortifying their grasp of secure and interactive web application
development.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Sunday, May 19, 2024
Topic Objective
• Explore the key features and benefits of Node.js that set it apart from traditional
server-side technologies.
• Learn how to navigate and work effectively within the Node.js environment.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Introduction & Environment Setup
Node.js is a powerful and versatile open-source runtime environment built on the V8 JavaScript engine.
It enables developers to execute JavaScript code outside the browser, on the server side, offering a
unique blend of performance, scalability, and flexibility.
Node.js has gained popularity for its ability to handle asynchronous operations efficiently, making it
particularly suitable for building real-time applications, APIs, and microservices.
By leveraging the event-driven, non-blocking architecture, Node.js has transformed the landscape of web
development, empowering developers to create fast and dynamic applications across various domains.
Node.js is an open-source, cross-platform runtime environment for developing server-side and networking
applications. It is built on top of the Google Chrome V8 JavaScript engine and is mainly used to create
web servers.
However, Node.js can also be used to build real-time applications, such as chat apps and streaming media
applications.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Introduction & Environment Setup
• Environment Setup of Node.js: Setting up the Node.js environment is a crucial initial step in harnessing its
capabilities for web development. The process involves a few essential steps:
1. Install Node.js: Begin by downloading the Node.js installer from the official website. Once
downloaded, run the installer and follow the on-screen instructions to complete the installation.
2. Verify Installation: After installation, open a terminal or command prompt and enter the command
node -v. This will display the installed version of Node.js, confirming a successful installation.
3. Node Package Manager (NPM): NPM comes bundled with Node.js and serves as a vital tool for
managing packages, dependencies, and modules. To check if NPM is installed, enter the command
npm -v in the terminal.
4. Creating Your First Application: Create a new directory for your Node.js project. Inside the directory,
create a file with a .js extension (e.g., app.js). Open the file with a code editor and start writing your
first Node.js application.
5. Running the Application: In the terminal, navigate to the project directory and run the application
using the command node app.js. You should see the output of your application in the terminal.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Introduction & Environment Setup
Here are the steps for practical on how to set up a Node.js environment:
3.Once the installer is finished, you will have Node.js installed on your computer.
4.To check if Node.js is installed correctly, open a terminal window and type the following command:
node -v
If Node.js is installed correctly, you should see the version number of Node.js printed to the console.
5.Once Node.js is installed, you need to install the Node Package Manager (NPM). NPM is a package manager for Node.js
applications.
It allows you to install third-party modules and libraries that are used in Node.js applications.
To install NPM, open a terminal window and type the following command:
npm install -g npm
This will install the latest version of NPM globally on your computer.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Introduction & Environment Setup
6.Now that you have Node.js and NPM installed, you are ready to start developing Node.js applications.
Here is a simple Node.js application that prints "Hello, world!" to the console:
server.listen(3000);
console.log('Server listening on port 3000’);
To run this application, save it as app.js and then type the following command in a terminal window:
node app.js
This will start the Node.js server and listen for connections on port 3000. If you open a web browser and go to
http://localhost:3000,
Sunday, May 19, 2024 you shouldSrishti
see Dikshit
the textWeb
"Hello, world!"
Development displayed
using MERN in the Unit
Stack with DevOps browser.
III
Introduction & Environment Setup Daily Quiz
1. What is the primary purpose of version control in software development?
a) To automate the build and deployment process
b) To manage project tasks and issues
c) To track changes in source code and enable collaboration
d) To create visually appealing user interfaces
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Introduction & Environment Setup Daily Quiz
5. How does version control support collaboration among developers working on the same project?
e) By providing a centralized server to host the codebase
f) By allowing developers to work offline and sync changes later
g) Restricting access to the codebase only to authorized users
h) By keeping track of changes made by different developers and enabling easy integration of their work
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Introduction & Environment Setup (Questions)
1.What is Node.js, and how does it differ from traditional server-side technologies?
2.Explain the significance of the V8 JavaScript engine in the context of Node.js.
3.What are the key features of Node.js that make it suitable for building real-time
applications?
4.Describe the process of setting up the Node.js development environment on your
local machine.
5.Why is it important to verify the installation of Node.js and NPM? How can you do
so?
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Topic Objective
Topic: Serving Static Resources & Template engine with Vash and Jade
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Serving Static Resources & Template engine with Vash and Jade
Serving Static Resources and Using Template Engines: Enhancing Web Applications
Serving static resources and utilizing template engines are essential techniques in web development for
creating dynamic and visually appealing web applications. These methods allow developers to efficiently
manage and present content to users while maintaining code organization and reusability.
1.Definition: Static resources include files such as HTML, CSS, JavaScript, images, and other assets that do not
change dynamically based on user interactions.
2.Static Resource Server: Web servers can be configured to serve static resources directly to clients without
processing them. This improves performance by reducing server load.
3.Benefits: Serving static resources from dedicated servers or content delivery networks (CDNs) can
accelerate page loading times and enhance user experience.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Serving Static Resources & Template engine with Vash and Jade
Template Engines:
1.Definition: Template engines allow developers to create dynamic HTML content by embedding placeholders
(variables) within templates. These placeholders are later replaced with actual data before rendering the content.
2.Dynamic Content: Template engines facilitate the generation of HTML with dynamic content, such as user-
specific data or database-driven information.
3.Code Reusability: Template engines promote code reusability by separating logic from presentation, enabling
developers to focus on functionality while designers focus on the layout.
4.Vash: Vash is a template engine for Node.js that supports the creation of dynamic HTML. It uses simple syntax
and allows for easy integration with Express.js.
5.Jade (Pug): Jade, now known as Pug, is another popular template engine for Node.js. It employs indentation-
based syntax and offers concise and expressive templates.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Serving Static Resources & Template engine with Vash and Jade
Serving static resources in Node.js is the process of making static files, such as images, CSS, and JavaScript,
available to users. This is typically done by creating a directory for static files and then configuring your web
server to serve those files from that directory.
There are a variety of ways to serve static resources in Node.js. Here are a few popular options:
• Express is a popular web framework for Node.js that includes support for serving static resources. To
serve static resources with Express, you can use the express.static() middleware.
• Hapi is a lightweight framework for Node.js that includes support for serving static resources. To serve
static resources with Hapi, you can use the server.route({ path: '/static/*', file: { path:
'./public' } }); method.
• Fastify is a high-performance framework for Node.js that includes support for serving static resources.
To serve static resources with Fastify, you can use the fastify.addStatic() method.
The best way to serve static resources in Node.js will depend on your specific needs and requirements. If you
are not sure which method to use, you can consult with a Node.js developer or architect.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Serving Static Resources & Template engine with Vash and Jade
The benefits of serving static resources in Node.js:
•It is scalable.
•It is secure.
•It is efficient.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Serving Static Resources & Template engine with Vash and Jade
The benefits and challenges:
If we are not sure if we are ready to serve static resources, you can start with a simple solution, such as using
the express.static() middleware. As the application grows and matures, we can then implement a more
complex solution, such as using a content delivery network (CDN).
Vash and Jade are two popular template engines for Node.js. Template engines are used to generate HTML
from templates. This can be useful for creating dynamic web pages that are personalized for each user.
Vash is a lightweight template engine that is easy to learn and use. It is also very fast, making it a good choice
for high-traffic applications. Jade is a more powerful template engine that offers a wider range of features.
However, it is also more complex to learn and use.
The best template engine for you will depend on your specific needs and requirements. If you are looking for
a lightweight and easy-to-use template engine, Vash is a good choice. If you need a more powerful template
engine with a wider range of features, Jade is a good choice.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Serving Static Resources & Template engine with Vash and Jade
Example of Using Template Engines (Pug):
html
head
title My Web Page
body
h1 Welcome to #{pageTitle}
p This is a dynamic web page using Pug template engine.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Serving Static Resources & Template engine with Vash and Jade
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Serving Static Resources & Template engine with Vash and Jade
Benefits of using template engines in Node.js:
• They can help you to create dynamic web pages that are personalized for each user.
• They can help you to save time and effort by automating the process of generating HTML.
• They can help you to improve the performance of your application by caching templates.
• They can help you to improve the security of your application by preventing XSS attacks.
If you are considering using template engines in Node.js, it is important to weigh the benefits and challenges
carefully. If you are not sure if you are ready to use template engines, you can start with a simple template
engine, such as Vash. As your application grows and matures, you can then implement a more complex template
engine, such as Jade. Serving static resources and employing template engines are fundamental techniques that
contribute to creating engaging and user-friendly web applications. By efficiently handling static assets and
generating dynamic content, developers can deliver appealing and interactive experiences to users.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Serving Static Resources & Template engine with Vash and Jade
2. How does serving static resources from dedicated servers or CDNs impact web performance?
e) It slows down page loading times
f) It has no impact on performance
g) It accelerates page loading times and improves user experience
h) It requires additional server processing for each resource
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Serving Static Resources & Template engine with Vash and Jade
4. Which template engine was previously known as "Jade" and is now called "Pug"?
a) Mustache
b) Handlebars
c) Vash
d) Pug
5. How does Vash or Jade (Pug) template engine improve code organization in web applications?
e) It replaces the need for CSS styles
f) It separates logic from presentation, promoting code reusability
g) It automatically generates database schemas
h) It serves as a content delivery network (CDN)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Serving Static Resources & Template engine with Vash and Jade
1. How does serving static resources from a content delivery network (CDN) contribute to faster web page loading
times?
2. Explain the term "template engine" and discuss its role in generating dynamic content.
3. Compare and contrast Vash and Jade (Pug) template engines in terms of syntax and features.
4. Describe the steps involved in using Express.js to serve static resources. How does it enhance website
performance?
5. Provide an example of a scenario where dynamic content is needed on a web page. How could a template
engine like Jade (Pug) fulfill this requirement?
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Topic Objective
• Acquire the skills to establish connections to databases, enabling data storage and
retrieval for dynamic applications.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Connecting Node.js to Database
There are many different ways to connect Node.js to a database. Here are a few popular options:
• MySQL is a popular relational database management system (RDBMS). There are many Node.js
modules that can be used to connect to MySQL, such as MySQL and MySQL2.
• MongoDB is a document database that is often used for storing JSON data. There are many Node.js
modules that can be used to connect to MongoDB, such as Mongo dB and Mongoose.
• PostgreSQL is a popular open-source relational database management system (RDBMS). There are
many Node.js modules that can be used to connect to PostgreSQL, such as pg and pg-promise.
• Cassandra is a distributed NoSQL database that is often used for storing large amounts of data. There
are many Node.js modules that can be used to connect to Cassandra, such as Cassandra and node-
Cassandra-driver.
The best way to connect Node.js to a database will depend on your specific needs and requirements. If you
are not sure which database to use, you can consult with a database administrator or developer.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Connecting Node.js to Database
Connecting Node.js to a database is a crucial step in building dynamic and data-driven applications.
Databases store, retrieve, and manage structured data, and integrating them with Node.js allows
developers to create powerful and scalable backends. Commonly used databases include relational
databases like MySQL and PostgreSQL, as well as NoSQL databases like MongoDB.
• Installing Dependencies: Use Node Package Manager (NPM) to install the required database driver
and any other dependencies.
• Establishing a Connection: Use the database driver to create a connection to the database server.
Provide connection details such as hostname, port, username, and password.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Connecting Node.js to Database
• Executing Queries: Once connected, you can execute queries or commands to interact with the database.
This includes operations like inserting, updating, retrieving, or deleting data.
• Handling Asynchronous Operations: Database operations are often asynchronous, so you'll need to use
callbacks, promises, or async/await to manage the flow of data and ensure responsiveness.
• Error Handling: Implement proper error handling to gracefully handle situations like connection failures
or query errors.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Connecting Node.js to Database
Example of connecting Node.js to a MySQL database using the mysql2 library:
This code will execute the SELECT * FROM users query on the MySQL database. The results variable will
contain an array of objects that represent the rows in the users table.
For more information on connecting Node.js to a database, you can consult the documentation for the specific
database module that you are using.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Connecting Node.js to Database Daily Quiz
1. What is the purpose of connecting Node.js to a database in web development?
a) To optimize website layout and design
b) To improve user interface responsiveness
c) To store, retrieve, and manage structured data
d) To enhance browser compatibility
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Connecting Node.js to Database Daily Quiz
5. How does Node Package Manager (NPM) contribute to connecting Node.js to a database?
e) NPM handles database operations automatically
f) NPM provides a visual interface for database connections
g) NPM allows you to install the required database driver and dependencies
h) NPM converts databases into NoSQL format
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Connecting Node.js to Database (Questions)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Topic Objective
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Mongoose Module
Simplifying MongoDB Interactions through Schema-Based Approach
The Mongoose module stands as a formidable asset within the Node.js ecosystem, offering a streamlined
conduit for orchestrating interactions with MongoDB databases.
The Mongoose module is a dynamic asset within the Node.js ecosystem, serving as a robust bridge
between applications and MongoDB databases.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Mongoose Module
Mongoose is a powerful tool that can be used to do a variety of things with MongoDB, such as:
•Create and manage collections. Collections are the equivalent of tables in a relational database. Mongoose
makes it easy to create and manage collections in MongoDB.
•Insert, update, and delete documents. Documents are the equivalent of rows in a relational database.
Mongoose makes it easy to insert, update, and delete documents in MongoDB.
•Query documents. Mongoose provides a powerful query language that you can use to query documents in
MongoDB.
•Enforce schemas. Mongoose allows you to enforce schemas on your documents. This ensures that your
documents are always consistent and valid.
•Handle relationships. Mongoose makes it easy to handle relationships between documents. This is useful for
modelling real-world entities.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Mongoose Module
The benefits of using Mongoose:
•It is easy to use. Mongoose provides a high-level abstraction for working with MongoDB, making it easy to
write efficient and scalable code.
•It is powerful. Mongoose provides a wide range of features for working with MongoDB, such as schema
validation, query building, and relationship handling.
•It is well-documented. Mongoose has extensive documentation that makes it easy to learn how to use the
module.
•It is actively maintained. Mongoose is actively maintained by a team of developers, which means that it is
constantly being updated with new features and bug fixes.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Mongoose Module
Let's delve into the Mongoose world with some illustrative code examples:
// Define a schema
const userSchema = new mongoose.Schema({
name: String,
email: { type: String, required: true, unique: true },
age: Number
});
mongoose.connect('mongodb://localhost/mydatabase', {
useNewUrlParser: true,
useUnifiedTopology: true
})
.then(() => {
console.log('Connected to MongoDB');
})
.catch((error) => {
console.error('Connection error:', error);
});
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Mongoose Module
4. Creating and Saving a Document:
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Mongoose Module
Exploring the Mongoose Module:
3. Data Validation: The schema-driven nature of Mongoose
At its core, Mongoose serves as an intermediary layer between paves the way for automatic data validation. This ensures
Node.js applications and MongoDB, ushering in an intuitive that data adheres to predefined rules before it integrates
paradigm that harmonizes data representation with the schema into the database, bolstering data integrity.
concept. This schema-driven approach bestows several
advantages: 4. Middleware Empowerment: Mongoose furnishes
developers with the capability to weave custom logic into
1.Structured Data Modeling: Mongoose empowers database operations. Middleware functions can be
developers to define data schemas that mirror real-world seamlessly integrated before or after actions like saving or
entities. Each schema prescribes the structure of documents, deleting documents, enabling tailored workflows.
delineating fields, their types, and validation constraints.
5. Enhanced Querying and Aggregation: Leveraging
2.Model Abstraction: With schemas in place, Mongoose Mongoose, developers harness a versatile toolkit for
engenders the creation of models that embody the data querying and aggregating data. Mongoose offers a wealth
structures. Models encapsulate crucial operations such as of query methods, and it harmonizes with MongoDB's
creating, reading, updating, and deleting documents, freeing aggregation framework for sophisticated data
developers from low-level database intricacies. manipulations.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Mongoose Module
Learning the Mongoose Craft:
• Embarking on the journey of mastering Mongoose entails traversing a landscape where schema
definitions crystallize real-world entities, models become conduits for interaction, and data validation
becomes second nature.
• Through the Mongoose module, developers are endowed with the artistry to sculpt database
interactions to their will, relinquishing mundane tasks to the background.
• In essence, Mongoose stands as a potent instrument, bridging the gap between application logic and
database intricacies.
• It harmonizes the seemingly disparate realms of Node.js and MongoDB, amalgamating them into a
seamless symphony of data-driven craftsmanship.
• The result is an elevated realm of data modelling and management that enhances the very essence of
database-driven applications.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Mongoose Module Daily Quiz
1. What is the primary purpose of the Mongoose module in Node.js?
a) To design user interfaces
b) To create web servers
c) To facilitate MongoDB interactions
d) To handle network requests
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Mongoose Module Daily Quiz
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Mongoose Module (Questions)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Topic Objective
• Master the concept of RESTful APIs and learn how to design and build APIs in
Node.js for seamless client-server communication.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Creating Rest APIs
Creating REST APIs: Building Web Services for Data Interaction
Creating Representational State Transfer (REST) APIs is a fundamental aspect of modern web development,
enabling seamless communication between clients and servers. REST APIs serve as a bridge, allowing
applications to request, retrieve, and manipulate data over the web.
REST APIs can be created in Node.js using a variety of frameworks and libraries. Here are a few popular
options:
• Express is a popular web framework for Node.js that makes it easy to create REST APIs.
• Loopback is a powerful framework for creating REST APIs that are both scalable and secure.
• Sails.js is a full-stack framework for Node.js that includes support for creating REST APIs.
• Hapi is a lightweight framework for creating REST APIs that is well-suited for microservices
architectures.
• Fastify is a high-performance framework for creating REST APIs that is well-suited for high-traffic
applications.
The best framework or library for creating REST APIs in Node.js will depend on your specific needs and
requirements. If you are not sure which framework to use, you can consult with a Node.js developer or architect.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Creating Rest APIs
Overview of the process involved in creating RESTful APIs:
1. Define Endpoints: Begin by identifying the resources your API will expose. Each resource should
correspond to a unique URL endpoint. For example, /users could represent a collection of user data.
2. Choose HTTP Methods: REST APIs use HTTP methods (verbs) to perform different actions on resources.
Common methods include GET (retrieve), POST (create), PUT (update), and DELETE (remove).
3. Design Data Representation: Determine how data will be represented in requests and responses. JSON
(JavaScript Object Notation) is a popular format for data exchange due to its simplicity and compatibility.
4. Create Routes and Handlers: In your server-side code (using a framework like Express in Node.js),
define routes that map to each API endpoint. Attach handlers to these routes to process incoming requests and
generate responses.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Creating Rest APIs
5. Implement CRUD Operations: For each resource, implement the four basic CRUD operations: Create,
Read, Update, and Delete. Associate these operations with the appropriate HTTP methods and route handlers.
6. Validate and Sanitize Data: Validate user input and sanitize data to prevent security vulnerabilities and
ensure data integrity. Input validation guards against invalid or malicious input.
7. Handle Errors and Responses: Incorporate error handling mechanisms to provide meaningful error
responses. Successful requests should yield appropriate status codes (e.g., 200 for success) and relevant
data.
8. Enable Cross-Origin Resource Sharing (CORS): If your API will be accessed from different domains,
configure CORS to allow cross-origin requests while maintaining security.
9. Versioning and Documentation: As your API evolves, consider implementing versioning to maintain
compatibility. Additionally, provide clear and comprehensive documentation for developers who will
consume your API.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Creating Rest APIs
Example of creating a REST API endpoint in Node.js using Express:
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
}); Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Creating Rest APIs
The basic steps involved in creating a REST API in Node.js:
1. Choose a framework or library. As mentioned above, there are many different frameworks and libraries
that you can use to create REST APIs in Node.js. Choose one that is well-suited for your needs and
requirements.
2. Define your endpoints. An endpoint is a URL that can be used to access a resource in your API. For
example, the endpoint /users might be used to retrieve a list of all users in your database.
3. Implement your endpoints. Once you have defined your endpoints, you need to implement them. This
involves writing code that will respond to requests to the endpoints.
4. Test your API. Once you have implemented your endpoints, you need to test your API to make sure that
it is working correctly. You can use a variety of tools to test your API, such as Postman or Insomnia.
5. Deploy your API. Once you are satisfied with your API, you need to deploy it so that it can be accessed
by other applications. You can deploy your API to a variety of platforms, such as Heroku, AWS, or Google
Cloud Platform.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Creating Rest APIs Daily Quiz
1. What does REST stand for in the context of web development?
a) Responsive State Transition
b) Representational State Transfer
c) Remote Server Transaction
d) Reactive Server Technology
3. Which HTTP method is typically used to retrieve data from a REST API?
i) POST
j) GET
k) PUT
l) DELETE
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Creating Rest APIs Daily Quiz
5. In REST API design, which HTTP method is often used to create new resources?
e) GET
f) POST
g) PUT
h) DELETE
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Creating Rest APIs (Questions)
1.Define RESTful APIs and explain their importance in modern web development.
2.What are the key principles of REST architecture, and how do they guide the design
of RESTful APIs?
3.Describe the main components of a typical REST API endpoint.
4.How do HTTP methods (GET, POST, PUT, DELETE) map to different actions in a
REST API?
5.Give an example of creating a simple REST API endpoint in a Node.js application.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Topic Objective
The Express framework is a robust and widely used web application framework for Node.js.
It provides a set of tools and features that simplify the process of building web applications
and APIs.
One of the key architectural patterns often used in conjunction with Express is the Model-
View-Controller (MVC) pattern.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Express Framework, MVC Pattern
Express Framework: Express offers a streamlined approach to developing web applications by providing:
1.Routing: Express allows you to define routes that map HTTP methods (GET, POST, etc.) to specific functions,
making it easy to handle different types of requests.
2.Middleware: Middleware functions can be used to process requests before they reach the route handler,
enabling tasks like authentication, logging, and error handling.
3.Template Engines: Express supports various template engines (such as EJS, Pug, and Handlebars) to
dynamically render HTML views.
4.Static Files: Serving static files (e.g., images, CSS, JavaScript) becomes effortless with Express's built-in
middleware.
5.Request and Response Objects: Express provides request and response objects that encapsulate useful
information and methods for working with client requests and server responses.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Express Framework, MVC Pattern
MVC Pattern:
The Model-View-Controller (MVC) pattern is an architectural paradigm that promotes separation of concerns in
software development. In the context of web applications:
1. Model: The model represents the application's data and business logic. It interacts with the database and
encapsulates data-related operations.
2. View: The view is responsible for presenting data to users. It generates the user interface and displays
information based on the model's data.
3. Controller: The controller acts as an intermediary between the model and the view. It handles user input,
processes requests, and updates the model or view accordingly.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Express Framework, MVC Pattern
When using Express, developers often follow the MVC pattern to achieve a structured and
modular codebase. Express routes act as controllers, handling requests and orchestrating
interactions between the model (data) and the view (UI).
The Express framework, when combined with the MVC pattern, empowers developers to create
organized, scalable, and maintainable web applications that efficiently handle routing, data
management, and user interface rendering.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Express Framework, MVC Pattern
Example of using Express with MVC pattern:
2. Which architectural pattern promotes separation of concerns and is often used in conjunction with Express?
e) REST pattern
f) MVC pattern
g) Singleton pattern
h) Observer pattern
3. In the context of the MVC pattern, what does the "Model" represent?
i) The user interface elements
j) The application's data and business logic
k) The network communication layer
l) The routing and middleware
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Express Framework, MVC Pattern Daily Quiz
5. Which Express feature is used to define routes and handle different types of HTTP requests?
e) Middlewares
f) Templates
g) Endpoints
h) Controllers
6. Which part of the MVC pattern acts as an intermediary between the "Model" and the "View"?
i) Controller
j) Router
k) Middleware
l) Template engine
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Express Framework, MVC Pattern (Questions)
1. What is the Express framework, and how does it facilitate web application development in Node.js?
2. Explain the role of middleware in the Express framework and provide examples of common middleware functions.
3. How do you create and configure routes in an Express application?
4. Describe the concept of template engines in Express and their role in generating dynamic HTML content.
5. What are the advantages of using Express to build APIs compared to traditional approaches?
6. Define the Model-View-Controller (MVC) architectural pattern and its significance in software development.
7. How does the MVC pattern help in organizing code and separating concerns in a Node.js application?
8. Explain the roles of the Model, View, and Controller components in the MVC pattern.
9. Give an example of how you would implement the MVC pattern in a Node.js application.
10.What benefits does the MVC pattern offer in terms of maintainability, scalability, and collaboration among
developers?
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Topic Objective
Topic: Routing
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Routing
Routing in Node.js is the process of directing requests to different parts of your application. This is done
by defining routes, which are mappings between URLs and functions. When a request is made to a URL
that matches a route, the function associated with that route is executed.
Routing is a core concept in web development that involves directing incoming requests to specific
handlers or functions based on the requested URL path and HTTP method. In the context of the Express
framework for Node.js, routing plays a pivotal role in defining how your application responds to different
routes and actions.
1. Defining Routes: Express provides a simple and declarative way to define routes using the app object.
Routes are typically associated with specific URL paths and HTTP methods.
2. Route Handlers: Each route is associated with a route handler, which is a function that executes when a
request matches the defined route. Route handlers can handle tasks such as processing data, interacting
with databases, and generating responses.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Routing
3. Dynamic Routes: Express supports dynamic route segments that can capture values from the URL.
These parameters are accessible within the route handler, allowing for dynamic data processing.
4. Route Parameters: Route parameters are denoted by a colon (:) followed by the parameter name in the
route definition. They provide a way to extract data from the URL and use it in the handler.
5. Route Chaining: Express allows you to chain multiple route handlers together for a single route. This
can be useful for applying middleware, performing authorization checks, or handling different aspects of
the request.
6. HTTP Methods: Routes can be associated with specific HTTP methods, such as GET, POST, PUT, and
DELETE. This enables you to differentiate between different types of actions.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Routing
Example of defining and handling routes in
Express
Example of defining and handling routes in Express:
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Routing
Express routing empowers developers to create structured and organized APIs and web applications.
By defining routes and associating them with specific actions, developers can efficiently manage the flow of
incoming requests and provide appropriate responses.
app.listen(3000, () => {
console.log('Server listening on port 3000');
});
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Routing
In this example, the route / is mapped to the function (req, res) => { res.send('Hello, world!'); }. This means
that when a request is made to the URL http://localhost:3000/, the function (req, res) => { res.send('Hello,
world!'); } will be executed.
Routes can be defined in a variety of ways, depending on the framework or library that you are using.
However, the basic idea is always the same: you need to define a mapping between a URL and a function.
Routing is a fundamental concept in Node.js web development. By understanding how routing works, you can
create applications that are easy to navigate and use.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Routing Daily Quiz
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Routing Daily Quiz
5. Which HTTP method is typically used to retrieve data from the server in Express routing?
e) POST
f) GET
g) PUT
h) DELETE
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Routing (Questions)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Topic Objective
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Cookies and Sessions
Cookies and Sessions: Managing User State in Web Applications
Cookies and sessions are essential components in web development that enable the management of user state
and data persistence between requests and responses. These mechanisms play a crucial role in enhancing user
experiences and providing personalized interactions on web applications.
Cookies:
1. Definition: Cookies are small pieces of data sent from a web server to a user's browser and stored on
the user's device. They are used to store information such as user preferences, session identifiers, and
tracking data.
2. Purpose: Cookies are often employed for tasks like user authentication, tracking user behavior, and
maintaining a user's shopping cart contents across different pages.
3. Types: Cookies can be categorized into two types: session cookies, which expire when the user closes
the browser, and persistent cookies, which remain on the user's device for a specified duration.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Cookies and Sessions
Sessions:
1. Definition: Sessions are a logical continuation of cookies. They allow web applications to track user
interactions over a series of requests and responses.
2. Session Management: When a user accesses a website, a unique session identifier is generated and
stored in a cookie. This identifier is used to associate subsequent requests from the same user with
the appropriate session data on the server.
3. Data Persistence: Sessions enable the storage of user-specific data, such as login credentials and
shopping cart contents, across multiple page views.
2. What type of cookie is stored on the user's device until a specified expiration time?
e) Session cookie
f) Persistent cookie
g) Transient cookie
h) Temporary cookie
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Cookies and Sessions Daily Quiz
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Cookies and Sessions (Questions)
1.Why are cookies and sessions essential for managing user interactions in web
applications?
2.Explain the difference between cookies and sessions and their respective use cases.
3.How can you implement user authentication and maintain user sessions using
cookies and sessions in Node.js?
4.Describe the process of creating and setting cookies in a Node.js application.
5.What security considerations should be taken into account when working with
cookies and sessions to prevent unauthorized access?
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Topic Objective
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
HTTP Interaction
Hypertext Transfer Protocol (HTTP) is the foundation of data communication on the World Wide Web. It
defines the rules and conventions for exchanging data between a client (such as a web browser) and a
server (hosting a website).
HTTP enables the retrieval of web resources, such as HTML pages, images, and files, and it forms the basis
for interactions between users and web applications.
1. Client-Server Model: HTTP operates on a client-server model, where the client initiates resource
requests, and the server responds with the requested data.
2. Request and Response Cycle: A typical HTTP interaction consists of a request sent by the client and a
corresponding response from the server. Each HTTP request contains a method (GET, POST, etc.) and a
URL, while the response includes a status code and the requested content.
3. HTTP Methods: HTTP defines several methods that indicate the desired action to be performed on
the server. Standard methods include GET (retrieve data), POST (submit data), PUT (update data), and
DELETE (remove data).
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
HTTP Interaction
4. Headers: HTTP headers provide additional information about the request or response, such as content
type, encoding, and authentication credentials.
5. Status Codes: HTTP status codes convey the outcome of a request. They indicate whether the request was
successful, redirected, or encountered an error.
6. Stateless Protocol: HTTP is stateless, meaning each request is independent of previous requests. To
maintain state across multiple requests, mechanisms like cookies and sessions are used.
7. URLs and Resources: URLs (Uniform Resource Locators) identify web resources and determine their
location on the internet.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
HTTP Interaction
HTTP Request:
GET /example.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
Example of an HTTP request and
response interaction: HTTP Response:
HTTP/1.1 200 OK
Date: Thu, 01 Jul 2023 15:30:00 GMT
HTTP interaction forms the backbone of web Content-Type: text/html
communication, enabling seamless data Content-Length: 2345
exchange and resource retrieval. It allows
users to access websites, submit forms, <!DOCTYPE html>
retrieve data, and interact with various web <html>
services and applications. <head>
<title>Example Page</title>
</head>
<body>
<h1>Welcome to the Example Page</h1>
</body>
</html>
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
HTTP Interaction Daily Quiz
What does HTTP stand for in web development?
a) Hypertext Transfer Protocol b)
b) Hyperlink Text Protocol c)
c) High-Traffic Transport Protocol d)
d) HTML Text Protocol
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
HTTP Interaction Daily Quiz
Which component of an HTTP response provides information about the content being sent?
e) Status code
f) Request URL
g) Response body
h) Request method
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
HTTP Interaction (Questions)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Topic Objective
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
User Authentication
User Authentication: Securing Access to Web Applications
User authentication is a critical aspect of web development that involves verifying the identity of users
before granting them access to protected resources or features within a web application.
It ensures that only authorized individuals can interact with sensitive data and perform specific actions,
contributing to the overall security and privacy of online systems.
User authentication in Node.js is the process of verifying the identity of a user. This is typically done by
requiring users to provide a username and password.
Once a user has been authenticated, they are granted access to the application.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
User Authentication
There are a variety of ways to implement user authentication in Node.js. Here are a few popular options:
• Session authentication is a simple and straightforward way to authenticate users. In session authentication, a unique
session ID is generated for each user. This session ID is stored in the user's browser and is used to authenticate the user on
subsequent requests.
• Token authentication is a more secure way to authenticate users than session authentication. In token authentication, a
token is generated for each user. This token is then used to authenticate the user on subsequent requests. Tokens are
typically more secure than session IDs because they are not stored in the user's browser.
• Basic authentication is a simple way to authenticate users over HTTP. In basic authentication, the user's username and
password are sent in clear text over the network. This is not a very secure way to authenticate users, but it is often used
for simple applications.
• OAuth 2.0 is a modern authentication protocol that is widely used by web applications. OAuth 2.0 allows users to
authenticate with a third-party service, such as Google or Facebook. This can be a convenient way for users to
authenticate with your application, as they do not need to create a new account with your application.
The best way to implement user authentication in Node.js will depend on your specific needs and requirements. If you
are not sure which method to use, you can consult with a Node.js developer or architect.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
User Authentication
Key Concepts of User Authentication:
1. Authentication Factors: User authentication typically involves one or more authentication factors:
something the user knows (password), something the user has (security token or device), or something
the user is (biometric data like fingerprints or facial recognition).
2. Authentication Process: When a user attempts to access a protected area, the application prompts
them to provide valid credentials. The credentials are compared against stored data to verify the user's
identity.
3. Credentials Storage: User credentials, such as passwords, are securely stored using encryption or
hashing techniques. Storing plain passwords is a security risk.
4. Session Management: After successful authentication, a session is established, allowing the user to
interact with the application without repeatedly entering credentials for each action.
5. Authorization: While authentication verifies identity, authorization determines the specific actions a
user is allowed to perform once authenticated.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
User Authentication
The benefits of implementing user authentication in Node.js:
• It can help to prevent users from accessing resources that they are not authorized to access.
• It can help to improve the user experience by providing a more secure and personalized experience.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
User Authentication
Authentication Methods:
1. Username and Password: The most common method, where users provide a unique username and
associated password.
2. Multi-Factor Authentication (MFA): Requires users to provide multiple types of authentication, adding
an extra layer of security.
3. Token-Based Authentication: Users are issued tokens after successful login, which are then used for
subsequent requests.
4. Biometric Authentication: Uses unique physical traits like fingerprints, retinal scans, or facial recognition
for verification.
Example of User Authentication Flow:
5. User visits a login page and enters their username and password.
6. The application validates the credentials against a database.
7. If the credentials are correct, the application generates a session token.
8. The session token is stored on the server and sent back to the user's browser as a cookie.
9. Subsequent requests include the session token, allowing the server to identify and authorize the user.
Effective user authentication is crucial for safeguarding sensitive data and maintaining the integrity of web
applications. By employing strong authentication methods and secure credential storage, developers can create a
trustful and secure user experience.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
User Authentication Daily Quiz
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
User Authentication Daily Quiz
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
User Authentication (Questions)
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit V
Topic Link (YouTube & NPTEL Video Links)
• https://youtu.be/BLl32FvcdVM
• https://youtu.be/fCACk9ziarQ
• https://youtu.be/YSyFSnisip0
• https://youtu.be/7H_QH9nipNs
• https://youtu.be/AX1AP83CuK4
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
MCQ (End of Unit)
1. What is the primary role of Node.js in web development?
a) Rendering dynamic web pages
b) Managing client-side scripts
c) Handling server-side logic
d) Designing user interfaces
4. Which tool is commonly used for managing Node.js versions and dependencies?
a) NPM (Node Package Manager)
b) Docker
c) Jenkins
d) MongoDB
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Glossary Questions
1. What is the primary function of a version control system?
2. Explain the concept of asynchronous programming.
3. How does a call-back function work in JavaScript?
4. Define the event loop in the context of Node.js.
5. What are streams and buffers in Node.js, and how are they used?
6. Describe the purpose of a database connection pool.
7. What is the role of a schema in the Mongoose module?
8. How do you define a RESTful API?
9. Explain the role of middleware in the Express framework.
10. What is the main purpose of the Model in the MVC pattern?
11. How does routing enable URL handling in web applications?
12. Describe the use of cookies in session management.
13. What is the significance of the HTTP protocol in web development?
14. Explain the concept of user authentication.
15. What is a package.json file, and what is its role in Node.js projects?
16. How does the 'require' function work in Node.js?
17. Describe the difference between synchronous and asynchronous operations.
18. What is an EventEmitter in Node.js, and how is it used?
19. How can you handle errors in a Node.js application?
20. Define the concept of middleware chaining in Express.
Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
Summary
In this comprehensive unit, students have embarked on an enriching journey through the world of Node.js
development. They were introduced to the fundamental concepts of Node.js and its role in modern web development,
followed by practical guidance on setting up a conducive development environment.
Exploring key tools like the Node Package Manager (NPM), students mastered the art of efficiently managing
dependencies and packages. They delved into the intricacies of asynchronous programming through callbacks, grasped
the event-driven architecture and event loop, and harnessed the power of streams and buffers for optimized data
processing.
Building on these foundations, students seamlessly connected Node.js to databases using the Mongoose module,
skilfully modelled data and created RESTful APIs, and harnessed the robust Express framework to build dynamic
applications following the MVC pattern.
With a keen understanding of routing, cookies, sessions, and HTTP interactions, students fortified their applications
with secure user authentication. As this unit concludes, students stand equipped with the knowledge and skills to craft
sophisticated Node.js applications, poised to embark on their next phase of web development mastery.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
References
1) Anthony Accomazzo, Ari Lerner, and Nate Murray, “Fullstack React: The Complete Guide to ReactJS and Friends”,
4th edition, 2020 International Publishing. 
2) David Cho, “Full-Stack React, Type Script, and Node: Build cloud-ready web applications using React 17 with Hooks
and GraphQL”, 2nd edition, 2017 Packt Publishing Limited.
3) Richard Haltman & Shubham Vernekar, “Complete node.js: The fast guide: Learn complete backend development with
node.js”5th edition, 2017 SMV publication.
4) Glenn Geenen, Sandro Pasquali, Kevin Faaborg, “Mastering Node.js: Build robust and scalable real-time server-side
web applications efficiently” 2nd edition Packt,2017 Publishing Limited.
5) Greg Lim,” Beginning Node.js, Express & MongoDB Development, kindle edition,2019 international publishing
6) Daniel Perkins, “ReactJS Master React.js with simple steps, guide and instructions” 3rd edition, 2015 SMV
publication.
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III
THANK YOU
Sunday, May 19, 2024 Srishti Dikshit Web Development using MERN Stack with DevOps Unit III