Ultimate Node.js for Cross-Platform App Development: Learn to Build Robust, Scalable, and Performant Server-Side JavaScript Applications with Node.js 9788196815158

Unleash the Power of Node.js for Building Enterprise-Grade, Scalable Server-Side Applications. Unlock the full potentia

123 29

English Pages 409 Year 2024

Report DMCA / Copyright

DOWNLOAD EPUB FILE

Table of contents :
Cover Page
Title Page
Copyright Page
Dedication Page
About the Author
About the Technical Reviewers
Acknowledgements
Preface
Errata
Table of Contents
1. Getting Started with Node.js
Introduction
Structure
History of Node.js
Defining Node.js
Features of Node.js
Reasons for Node.js Popularity
Node.js versus Browser JavaScript
Installing Node.js
Installing NVM on Windows
Verifying NVM Installation
Some Core Concepts of Node.js
V8 Engine
Blocking versus Non-blocking Operations
Event Loop
Callback functions
Defining Callback Hell in Node.js
Ways to Avoid Callback hell
Promise
Async and Await
Choosing the Appropriate Approach
REPL Console
Getting Started with the REPL
Using NPM and Package.json
Init
Install
Installing Single Package
Update
Attributes of Package.json
The First Console Application Using Node.js
The First Web Application Using Node.js
Conclusion
Further Readings
Test Your Node.js Basic Knowledge
Answers
2. Deep Dive into Node.js
Introduction
Structure
Traditional Web Application Architecture
Architecture of Node.js
Event Loop
Phase Methods in Details
Non-blocking or Asynchronous I/O
Bank and Cafe
Core Node Modules
Buffers
Creating Buffers
Writing Buffers
Reading from Buffers
Converting Buffer to JSON
Concatenating Buffers
Comparing Buffers
Copying Buffer
Events
Emit an event with arguments
Detach an event listener
Extend the EventEmitter class
File System
File Reading
File Open
File Information
HTTP
Path
Process
Stream
Reading from Stream
Writing to Stream
Piping Stream
Chaining Stream
Conclusion
Questions
Answers
3. Introducing Express.js
Introduction
Structure
Express.js Overview
Key Features of Express.js
Benefits of Express.js
Installing Express.js
How Express.js Works
Adding Routes in Express
Request/Response Object
Using Middleware in Express
Application-level middleware
Router-level middleware
Error-handling middleware
Built-in middleware
Third-party middleware
Serving Static Files
Express Application Generator
Conclusion
Questions
Answers
4. Creating REST API and Routing
Introduction
Structure
Introduction to RESTful Services
Benefits of RESTful APIs
Different Kinds of HTTP Verbs
Idempotency of Different HTTP Verbs
How RESTful APIs Work
Creating the First HTTP Server
Adding Routes
Using Swagger with Node.js
Setting up Swagger in Node.js
Request Validations
Validating Request Body
Request Transformation
Response Transformation
Understanding HTTP Status Codes
CORS Request Handling with Express
Configuring CORS with Express
API Error Handling
Conclusion
Further Readings
5. Working with MongoDB
Introduction
Structure
Introducing Database
Use Case of Database
Types of Database
Advantages of Using Databases
Disadvantages of Using Databases
Database Management System (DBMS)
Usage of DBMS
Types of Data Models in DBMS
Advantages of DBMS
Disadvantages of DBMS
ACID Properties in DBMS
Basics of MongoDB
RDBMS versus MongoDB
Key Components of MongoDB Architecture
How MongoDB Works
Features of MongoDB
Advantages of MongoDB
Disadvantages of MongoDB
Installing MongoDB on Windows
Creating our First Connection to MongoDB
Mongo Shell for MongoDB
Installing the Mongo Shell
Connecting to MongoDB Database
Running Mongo Shell Application
Basic Commands for Mongo Shell
Introduction to MongoDB Compass
Installation of Compass on Windows
Conclusion
Further Readings
6. Data Persistence
Introduction
Structure
Understanding ORM Tool
Introduction to Mongoose
Characteristics of Mongoose
Advantages of Mongoose
Disadvantages of Mongoose
Key Terminologies
Schema and Model
Connecting to MongoDB through Mongoose
Database connection
Basic Mongoose Operations
Create operation
Retrieve operation
Update operation
Delete operation
Real-world Example
Conclusion
Further Reading
7. Template Engines
Introduction
Structure
Templating engines
Working of template engines
Advantages of template engines
Disadvantages of template engines
Key components of template engines
HTML rendering with templates
Exploring the EJS template engine
Creating dynamic content using EJS
Conclusion
Further readings
8. Middleware Functions
Introduction
Structure
Introduction to Middleware
Importance of Middleware
Advantages of Using Middleware
Key Components of Middleware
Understanding the Next( ) Function
Using Inbuilt Middleware with Express
Types of Express Middleware
Application-level Middleware
Router-level Middleware
Built-in Middleware
Error Handling with Middleware
Third-party Middleware
List of Third-party Middleware
Creating our First Custom Middleware
Middleware Chaining
Conclusion
Further Readings
9. Authentication and Authorization
Introduction
Structure
Introduction to Authentication and Authorization
Brief about Authentication
Importance of Authentication
Authentication Types
Popular Authentication Techniques
Password-based Authentication
Passwordless Authentication
2FA/MFA
Single Sign-On (SSO)
Social Authentication
Brief about Authorization
Importance of Authorization
Authorization Techniques
Role-based Access Control
JSON Web Token
SAML
OpenID Authorization
OAuth
Difference between Authentication and Authorization
Securing Real-World APIs
Running Application
Conclusion
Further Readings
10. Socket.IO
Introduction
Structure
Exploring WebSocket programming
Introducing WebSocket
Usage of WebSockets
Advantages of WebSocket
Disadvantages of WebSocket
WebSocket versus HTTP
Establishing WebSocket Connections
WebSocket Protocol
Using Socket.IO with Express
Communication between Client and Server
Reasons to Choose Node.js and Socket.IO
Creating a Simple Chat Application
Conclusion
Further Readings
11. Handling and Logging Errors
Introduction
Structure
Defining Errors in JavaScript
Types of Errors
Defining Error Handling in JavaScript
Factors Causing Errors in Node.js
Types of Errors in Node.js
Functional Errors
Programming Errors
Understanding Error Handling in Depth
Error Handling Inside Express
Express.js Default Error Handling
Custom Error Handling
Handling Errors Using Middleware Functions
Adding Multiple Middleware Handlers
Building Express Applications with Error Handling
Logging Errors in Node.js Application
Using Winston Logger
Conclusion
Further Readings
12. TDD with Mocha and Chai
Introduction
Structure
Node.js Unit Testing Concepts
Importance of Unit Testing
Test-Driven Development Fundamentals
Test-Driven Development Workflows
Key Principles of Test-Driven Development
Different Types of Testing Frameworks
Unit Testing key concepts
Advantages of Unit Testing in Node.js
Node.js Unit Test Anatomy
Advantages of using Mocha and Chai
Practical tips for writing unit tests
Methods to write unit tests
Introduction to Behavior-Driven Development (BDD)
BDD and Unit Testing
Key Benefits of BDD
Installation of Mocha and Chai
Hooks used in writing Unit Tests
BeforeEach
AfterEach
Spices
Stubs
Mocks
Async code
Callback and Promise
Conclusion
Further Readings
13. Debugging
Introduction
Structure
Introduction to Debugging
Importance of Debugging
Debugging Strategies
Debugging Techniques
Using Console.log
Using Node Inspector
Using Node.js debug module
Debugging an Express Application
Creating a Node.js application
Installing the Node.js debugger using “Nodemon”
Start debugging in VS Code
Run the debugger with Breakpoint
Conclusion
Further Readings
14. Build and Deployments
Introduction
Structure
Creating an NPM Package
Initializing Git Repository
Initializing NPM
Creating the First NPM Package
Testing the NPM Package
Running test application
Publishing Your NPM Package
Introduction to Continuous Integration and Continuous Delivery
Defining Continuous Integration (CI)
Defining Continuous Delivery (CD)
Defining Continuous Deployment (CD)
Defining Continuous Testing (CT)
Key elements of CI/CD
Importance of CI/CD
Deployment Service
Deployment pipeline
Advantages of pipeline deployment
Key components of the deployment pipeline
Stages of Deployment Pipeline
Introduction of pipeline tools
Deploying Node.js applications Using Docker
Creating a demo project
Creating Dockerfile
Building the Docker image
Running docker image as a container
Kubernetes Introduction
Key Components of Kubernetes
Kubernetes deployment and services background
Deploying Node.js applications to a Kubernetes cluster
Conclusion
Further Readings
15. Future Scope
Introduction
Structure
Distributed Systems
Centralized systems vs Distributed systems
Key Features of Distributed Architecture
Advantages of distributed systems
Disadvantages of distributed systems
Event-based programming
Building event-driven applications in Node.js
Messaging systems like Kafka
Key concepts of Kafka
Running Kafka locally
Multi-threaded system
Advantages of Multithreading
Running parallel child processes in Node.js
Define Worker Threads
Use of worker threads
Child process example
Conclusion
Further Readings
Index

Ultimate Node.js for Cross-Platform App Development: Learn to Build Robust, Scalable, and Performant Server-Side JavaScript Applications with Node.js
 9788196815158

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
Recommend Papers