Playlist Link
Playlist Link
NodeJS
Complete Course
Introduction to NodeJS
1. Pre-requisites
2. What is NodeJS
3. NodeJs Features
4. JavaScript on Client
5. JavaScript on Server
6. Client Code vs Server Code
7. Other uses of NodeJs
8. Server architecture with NodeJs
JS is required for NodeJS
React is recommended before NodeJS
2.What is NodeJS
1. File System Access: Provides APIs to read and write files directly,
which is not possible in browser environments for security
reasons.
2. Server-Side Capabilities: Node.js enables JavaScript to run on the
server, handling HTTP requests, file operations, and other
server-side functionalities.
3. Modules: Organize code into reusable modules using require().
3. NodeJs Features
(Removed)
3. NodeJs Features
4. JavaScript on Client
5. JavaScript on Server
6. Client Code vs Server Code
7. Other uses of NodeJs
8. Server architecture with NodeJs
2. Installation of NodeJS
1. What is IDE
2. Need of IDE
3. MAC Setup
• Install latest Node & VsCode
4. Windows Setup
• Install latest Node & VsCode
5. Linux Setup
• Install latest Node & VsCode
6. VsCode (Extensions and Settings)
7. Executing first .js file
8. What is REPL
9. Executing Code via REPL
2.1 What is IDE
1. IDE stands for Integrated
Development Environment.
2. Software suite that
consolidates basic tools
required for software
development.
3. Central hub for coding,
finding problems, and testing.
4. Designed to improve
developer efficiency.
2.2 Need of IDE
1. Streamlines development.
2. Increases productivity.
3. Simplifies complex tasks.
4. Offers a unified
workspace.
5. IDE Features
1. Code Autocomplete
2. Syntax Highlighting
3. Version Control
4. Error Checking
2.3 MAC Setup
• Click to edit Master text styles
• Second level
• Third level
• Fourth level
• Fifth level
2.3 MAC Setup
(Install latest Node)
Search Download NodeJS
2.3 MAC Setup
(Install VsCode)
• Click to edit Master text styles
Search VS Code on Google
• Second level
• Third level
• Fourth level
• Fifth level
2.4 Windows Setup
• Click to edit Master text styles
• Second level
• Third level
• Fourth level
• Fifth level
2.4 Windows Setup
(Install latest Node)
Search Download NodeJS
2.4 Windows Setup
(Install VsCode)
Search
• Click toVS
editCode
Master on
text Google
styles
• Second level
• Third level
• Fourth level
• Fifth level
2.5 Linux Setup
2.5 Linux Setup
(Install latest Node)
Search Download NodeJS
2.5 Linux Setup
(Install VsCode)
Search
• Click toVS
editCode
Master on
text Google
styles
• Second level
• Third level
• Fourth level
• Fifth level
2.6 VsCode
(Extensions and Settings)
1. • Click toisedit
What IDE Master text styles
• Second level
2. Need• Third
of level
IDE
• Fourth level
3. MAC Setup • Fifth level
• Install latest Node & VsCode
4. Windows Setup
• Install latest Node & VsCode
5. Linux Setup
• Install latest Node & VsCode
6. VsCode (Extensions and Settings)
7. Executing first .js file
8. What is REPL
9. Executing Code via REPL
3. First Node Server
1. How DNS Works?
2. How Web Works?
3. What are Protocols?
4. Node Core Modules
5. Require Keyword
6. Creating first Node Server
3.1 How DNS Works?
1. Domain Name Entry: User types a domain (e.g.,
www.example.com) into the browser.
2. DNS Query: The browser sends a DNS query to resolve
the domain into an IP address.
3. DNS Server: Provides the correct IP address for the
domain.
4. Browser Connects: The browser uses the IP to connect
to the web server and loads the website.
3.1 How DNS Actually Works?
1. Root DNS: Acts as the starting point for DNS resolution. It
directs queries to the correct TLD server (e.g., .com, .org).
2. TLD (Top-Level Domain) DNS: Handles queries for specific
top-level domains (e.g., .com, .net) and directs them to the
authoritative DNS server (e.g., Verisign for .com, PIR for .org)
3. Authoritative DNS: Contains the actual IP address of the
domain and answers DNS queries with this information.(e.g.,
Cloudflare, Google DNS).
3.2 How Web Works?
1. Client Request Initiation: The client (browser) initiates a
network call by entering a URL.
2. DNS Resolution: The browser contacts a DNS server to
get the IP address of the domain.
3. TCP Connection: The browser establishes a TCP
connection with the server's IP address.
4. HTTP Request: The browser sends an HTTP request to
the server.
5. Server Processing: The server processes the request and
prepares a response.
6. HTTP Response: The server sends an HTTP response back
to the client.
7. Network Transmission: The response travels back to the
client over the network.
8. Client Receives Response: The browser receives and
interprets the response.
9. Rendering: The browser renders the content of the
response and displays it to the user.
3.3 What are Protocols?
Http (HyperText Transfer Protocol):
● Facilitates communication between a web browser and a server to
transfer web pages.
● Sends data in plain text (no encryption).
● Used for basic website browsing without security.
HTTPS (HyperText Transfer Protocol Secure):
● Secure version of HTTP, encrypts data for secure communication.
● Uses SSL/TLS to encrypt data.
● Used in online banking, e-commerce.
TCP (Transmission Control Protocol):
● Ensures reliable, ordered, and error-checked data delivery over the
internet.
● Establishes a connection before data is transferred.
3.4 Node Core Modules
1. Built-in: Core modules are included
with Node.js installation.
2. No Installation Needed: Directly
available for use without npm
install.
3. Performance: Highly optimized for
performance.
3.4 Node Core Modules
1. fs (File System): Handles file operations like reading and
writing files.
2. http: Creates HTTP servers and makes HTTP requests.
3. https: Launch a SSL Server.
4. path: Provides utilities for handling and transforming file
5. paths.os: Provides operating system-related utility methods
and properties.
6. events: Handles events and event-driven programming.
7. crypto: Provides cryptographic functionalities like hashing and
encryption.
8. url: Parses and formats URL strings.
3.5 Require Keyword
1. Purpose: Imports modules in Node.js. Syntax:
2. Caching: Modules are cached after the const moduleName = require('module’);
first require call.
3. .js is added automatically and is not
needed to at the end of module name.
4. Path Resolution: Node.js searches for
modules in core, node_modules, and file
paths.
3.6 Creating first Node Server
3.6 Creating first Node Server
3.6 Creating first Node Server
node app.js
3.6 Creating first Node Server
3.6 Creating first Node Server
Revision
• Click to edit Master text styles
1. How
• SecondDNSlevel
• Third level
Works?
2. How Web Works?
• Fourth level
• Fifth level
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
4.3 Understand Request Object
1. Streams
2. Chunks
3. Buffers
4. Reading Chunk
5. Buffering Chunks
6. Parsing Request
7. Using Modules
5.1 Streams
5.1 Streams
5.2 Chunks
5.2 Chunks
5.3 Buffers
5.4 Reading Chunk
5.5 Buffering Chunks
5.6 Parsing Request
5.6 Parsing Request
5.7 Using Modules
5.7 Using Modules
Practise Set
Create a Calculator
1. Create a new Node.js project named “Calculator”.
2. On the home page (route “/”), show a welcome message and a
link to the calculator page.
3. On the “/calculator” page, display a form with two input fields
and a “Sum” button.
4. When the user clicks the “Sum” button, they should be taken to
the “/calculate-result” page, which shows the sum of the two
numbers.
○ Make sure the request goes to the server.
○ Create a separate module for the addition function.
○ Create another module to handle incoming requests.
○ On the “/calculate-result” page, parse the user input, use
the addition module to calculate the sum, and display the
result on a new HTML page.
Revision
• Click to edit Master text styles
1. Streams
• Second level
• Third level
3. Buffers
4. Reading Chunk
5. Buffering Chunks
6. Parsing Request
7. Using Modules
6. Event Loop
1. Event Driven
2. Single Threaded
3. V8 vs libuv
4. Node Runtime
5. Event Loop
6. Async Code
7. Blocking Code
6.1 Event Driven
6.2 Single Threaded
6.3 V8 vs libuv
V8:
1. Open-source JavaScript engine by Google.
2. Used in Chrome and Node.js.
3. Compiles JavaScript to native machine
code.
4. Ensures high-performance JavaScript
execution.
libuv:
1. Multi-platform support library for Node.js.
2. Handles asynchronous I/O operations.
3. Provides event-driven architecture.
4. Manages file system, networking, and
timers non-blockingly across platforms.
6.4 Node Runtime
6.4 Node Runtime
6.4 Node Runtime
6.4 Node Runtime
6.5 Event Loop
● timers: this phase executes callbacks
scheduled by setTimeout() and
setInterval().
● pending callbacks: executes I/O callbacks
deferred to the next loop iteration.
● idle, prepare: only used internally.
● poll: retrieve new I/O events; execute I/O
related callbacks (almost all with the exception
of close callbacks, the ones scheduled by
timers, and setImmediate()); node will
block here when appropriate.
● check: setImmediate() callbacks are
invoked here.
● close callbacks: some close callbacks, e.g.
socket.on('close', ...).
6.5 Event Loop
6.6 Async Code
6.6 Async Code
6.7 Blocking Code
6.7 Blocking Code
Run & Observe
Blocking vs Async
const fs = require('fs');
// Timer queue
setTimeout(() => console.log('3. Timer 1'), 0);
// I/O queue
const fs = require('fs');
fs.readFile('user-details.txt', () => console.log('4. I/O operation'));
// Check queue
setImmediate(() => console.log('5. Immediate 1'));
// Close queue
process.on('exit', (code) => {
console.log('6. Exit event');
});
1. • Click
Event to edit Master text styles
• Second levelDriven
• Third level
2. Single Threaded
• Fourth level
• Fifth level
3. V8 vs libuv
4. Node Runtime
5. Event Loop
6. Async Code
7. Blocking Code
7. NPM & Tools
npm install
Recreates node_modules
7.7 Using nodemon
3. npm Scripts
4. npm Packages
5. Installing Packages
6. Installing nodemon
7. Using nodemon
8. Errors & Debugging
1. Types of Errors
2. Syntax Errors
3. Runtime Errors
4. Logical Errors
5. Using the Debugger
6. Debugger with Async Code
7. Restart Debug with nodemon
8.1 Types of Errors
Step 2
8.5 Using the Debugger
Step 4: Use the tools Step 6: Debug Panel
Step 5: Hover
8.5 Using the Debugger
Step 7: Using Debug Console
8.6 Debugger with Async Code
8.7 Restart Debug with nodemon
Practise Set
Debug and fix Syntax, Runtime and Logical Errors
function calculateArea(width, height {
return width + height;
}
2. Syntax Errors
• Fifth level
3. Runtime Errors
4. Logical Errors
5. Using the Debugger
6. Debugger with Async Code
7. Restart Debug with nodemon