NODEJS Contents

Node.js

Node.js allows JavaScript to run on the server. Learn how to build APIs, manage async operations, and run scalable backend services.

150 lessons · 0 examples

Foundations & Runtime(17)

Node.js HOME
A production-focused Node.js backend handbook built around real-world architecture, TypeScript-first development, and modern API design principles.
Node.js Intro: What Problem Does It Solve?
Understand what Node.js really is, how its runtime works, and why its event-driven model makes it powerful for building scalable backend systems.
Event Loop Explained
Learn how the Node.js event loop works, how microtasks and macrotasks are scheduled, and why understanding this model is critical for production stability.
Get Started: Install Node and Run Your First Script
Set up a TypeScript-first Node.js project with a clean dev workflow, understand LTS choices, and establish production-friendly habits from day one.
System Requirements and LTS Strategy
Understand Node.js versioning, LTS strategy, system requirements, and the tooling expectations for building stable backend applications.
Node.js vs Browser JavaScript
Explore the key differences between Node.js and browser JavaScript, including global objects, APIs, security boundaries, and runtime capabilities.
V8, libuv, and the Node Runtime Model
Understand how the V8 engine executes JavaScript, how memory management works, and how Node integrates V8 with libuv to power backend applications.
Node Architecture: Threads, I/O, and the Main Loop
Explore Node.js internal architecture, including V8, libuv, the event loop, thread pool, and how these components work together to handle requests efficiently.
Event Loop Basics (What Actually Runs When)
Understand the basic cycle of the Node.js event loop and how tasks move through its execution phases.
Microtasks vs Macrotasks (Promises vs Timers)
Learn how microtasks like Promises and process.nextTick are prioritized in the Node.js event loop.
Concurrency Model: Non-blocking I/O Explained
Understand how Node.js handles concurrency using non-blocking I/O instead of multi-threaded request handling.
The process Object: Args, Env, Exit Codes
Learn how the Node.js process object works, including environment variables, arguments, and lifecycle events.
Environment Variables: Patterns and Gotchas
Learn how environment variables work in Node.js, how to structure configuration safely, and how to avoid common production mistakes.
TypeScript-first Node: Project Setup (Minimal Tooling)
Set up and structure a TypeScript-first Node.js project with scalable configuration and clean runtime boundaries.
JS vs TS in Node: Quick Differences You’ll See Often
Understand practical differences between JavaScript and TypeScript in Node projects and how they impact runtime behavior.
Node LTS, Releases, and Upgrade Strategy
Understand Node.js release cycles, LTS policy, and how version strategy impacts backend stability.
When NOT to Use Node.js (Real Tradeoffs)
Learn when Node.js is not the right tool and how to recognize architectural mismatches early.

Async Programming(11)

Async in Node: Mental Model
Understand asynchronous programming in Node.js, why it exists, and how it enables scalable backend systems without multi-threaded request handling.
Callbacks (Why They Still Matter)
Learn how callbacks work in Node.js, why they were the original async pattern, and what problems they introduced.
Promises Deep Dive (Chaining, States, Errors)
Understand Promises in Node.js, how they represent future values, and how they improve async control flow.
Async/Await Under the Hood
Learn how async/await simplifies promise-based code and how to use it safely in production systems.
Error Propagation Across Async Boundaries
Understand how errors propagate across async boundaries and how improper handling leads to unstable services.
try/catch Pitfalls with Async Code
Learn how try/catch behaves with async/await and how to avoid common mistake patterns in error handling.
Timeouts & Retries (Without Making a Mess)
Learn how to implement timeouts and retry strategies for external service calls in production systems.
AbortController in Node (Canceling Work)
Learn how to cancel asynchronous operations in Node.js using AbortController and why cancellation is critical for robust systems.
Parallel vs Concurrent Work in Node
Understand controlled parallel execution in Node.js using Promise.all, worker threads, and concurrency limits.
Unhandled Rejections: What to Do in Production
Learn how unhandled promise rejections behave in Node.js and how to prevent silent crashes in production.
Common Async Bugs and How to Avoid Them
Identify common async programming mistakes in Node.js and learn how to prevent subtle race conditions and logic errors.

Modules & Tooling(11)

Modules Overview: CommonJS vs ES Modules
Get a clear mental model of how Node.js loads code, why CommonJS and ES Modules both exist, and how to choose a module strategy for production projects.
ES Modules in Node (import/export, package.json type)
Learn how ES Modules work in Node.js, how to configure them correctly, and how to avoid the most common ESM pitfalls in real-world backend projects.
CommonJS (require/module.exports) in Legacy Code
Understand how CommonJS works in Node.js, why it became the default module system, and how it differs from ES Modules in real-world backend projects.
How Node Resolves Modules (Paths, Exports, Conditions)
Understand how Node.js resolves module paths, how package resolution works, and how exports, main, and index files affect runtime behavior.
package.json Essentials (name, main, exports, types)
Learn how package.json controls module behavior, scripts, dependency management, runtime configuration, and production deployment strategy in Node.js projects.
npm Basics: Installing, Lockfiles, and Reproducibility
Understand how npm works under the hood, how dependency installation and lock files operate, and how to manage packages safely in production environments.
npm Scripts: Dev/Build/Test Workflow
Learn how to design npm scripts for a clean dev/build/test workflow, avoid cross-platform pitfalls, and keep production execution predictable.
Managing Dependencies: Semver, Updates, and Audits
Learn how to manage dependencies safely with semver, lockfiles, audits, and update strategies to keep Node.js backends stable in production.
Monorepo Basics (When It Helps, When It Hurts)
Learn what a monorepo is, when to use it in Node.js backend systems, and how it affects dependency management, shared code, and deployment strategy.
Project Structure: Feature vs Layer Folders
Learn practical project structures for Node.js backends, how to avoid spaghetti imports, and how to organize code for scale, testing, and long-term maintenance.
Linting & Formatting (ESLint/Prettier strategy)
Learn how to use ESLint and Prettier in Node.js projects to enforce code quality, prevent common mistakes, and maintain consistency across teams.

Core Modules(11)

fs Basics: Reading and Writing Files Safely
Use fs safely in production by choosing async APIs, streaming large files, and applying atomic write patterns to protect latency and data integrity.
path vs URL: Correctly Handling Paths and Links
Avoid cross-platform bugs by using path for filesystem resolution and URL for network-safe parsing, especially in ESM and container environments.
Streams Intro: Why Streams Exist
Use streams to process large data with constant memory, predictable latency, and safer error propagation in production pipelines.
Backpressure: The Real Reason Your Server Slows Down
Backpressure is how Node prevents memory blowups by slowing producers when consumers cannot keep up; you must respect it in streaming systems.
Buffer: Binary Data Without Fear
Buffers power binary I/O in Node; mastering encoding and memory behavior is essential for networking, files, and crypto workloads.
events & EventEmitter: Patterns and Pitfalls
EventEmitter is Node's core abstraction for decoupling modules, but must be managed to avoid leaks and unbounded listener growth.
crypto Basics: Hashing vs Encryption
Use Node's crypto primitives for hashing and integrity, but prefer proven higher-level libraries for passwords and protocols.
Timers: setTimeout/setInterval and Drift
Timers schedule work but can silently increase event-loop latency; use them intentionally and offload heavy callbacks.
readline: CLI Input for Real Tools
Readline is for production-grade CLI tooling: interactive prompts, controlled input, and safe termination for ops workflows.
util & Debugging Helpers (inspect, promisify)
util tools improve debugging and introspection; in production, prefer structured inspection over brittle JSON serialization.
dns Module: When You Actually Need It
DNS behavior affects latency and service discovery; control lookups carefully and cache in high-throughput systems.

HTTP & Networking(11)

Raw HTTP Server: A Minimal API Without Frameworks
Build production-grade HTTP servers in Node.js with full control over the event loop, lifecycle, and performance characteristics.
Routing Basics Without Express
Implement routing manually to understand request dispatching, performance trade-offs, and framework abstractions.
Parsing JSON Bodies Safely
Safely parse request bodies and JSON payloads while protecting memory and preventing denial-of-service vulnerabilities.
Status Codes That Don’t Hurt Users
Use HTTP status codes intentionally to communicate system state, validation errors, and failure semantics.
HTTPS/TLS Basics for Backend Devs
Understand TLS fundamentals and when to terminate HTTPS at Node versus a reverse proxy.
CORS Basics (and Why It’s Not “A Backend Bug”)
CORS controls browser cross-origin access. Misconfiguration can expose internal APIs unintentionally.
HTTP/2 Overview (What Changes, What Doesn’t)
HTTP/2 improves multiplexing and header compression, reducing latency in high-concurrency systems.
WebSockets Overview (When REST Isn’t Enough)
WebSockets enable persistent bidirectional communication beyond request-response patterns.
Socket.IO vs ws: Tradeoffs
Understand differences between ws and Socket.IO to choose the right abstraction for real-time systems.
HTTP Timeouts (Server, Client, and Proxies)
Timeout configuration protects your server from slow clients and resource exhaustion attacks.
Streaming Responses (SSE/Chunked) Overview
HTTP streaming allows progressive responses and efficient large data delivery without buffering entire payloads.

Express.js(16)

Express Intro
Express is the pragmatic HTTP layer for Node.js: minimal, fast to ship, and flexible enough for production when you enforce structure, safety, and observability.
What Express Is (and What It Isn’t)
Express is a middleware-first routing library built on Node's HTTP primitives; understanding the request lifecycle is the key to building reliable systems with it.
Express + TypeScript: Minimal Setup
A production Express setup is mostly about TypeScript, environment configuration, safe defaults, and a clean module layout—not about adding more dependencies.
Routing Patterns (params, query, nesting)
Production routing is about clear boundaries and predictable behavior: define routes as contracts and keep business logic out of handlers.
Middleware Concept: The Request Pipeline
Middleware is where production behavior lives: auth, validation, logging, rate limiting, and error translation should be expressed as composable middleware.
Error Middleware: One Place to Handle Failures
Error middleware is the reliability backbone: normalize failures into a stable response shape while preserving logs, stack traces, and root causes.
Validation Strategy (DTOs + schema validation)
Validation is an API boundary concern: reject bad input early, return actionable errors, and keep business logic pure and trustable.
Async Errors in Express (the safe pattern)
Async errors are the most common Express footgun; production apps must ensure promise rejections always reach the error handler.
Request Context (correlation id, per-request state)
Request context enables correlation IDs, scoped logging, and per-request metadata without leaking state across concurrent requests.
Serving Static Files (and when not to)
Serving static files is easy, but production needs caching strategy, immutable assets, and safe directory boundaries to avoid accidental exposure.
Rate Limiting: Basic Protection
Rate limiting protects availability and cost by reducing abusive traffic, brute force attempts, and noisy clients hitting expensive endpoints.
Security Headers with helmet (baseline)
Helmet sets security headers that reduce common web attack surfaces; it is a production default, not an optional add-on.
HTTP Logging Middleware (what to log)
Logging is your production memory: use structured logs with request IDs, latency, and error context to debug fast and measure reality.
Express Best Practices Checklist
Express scales in production when you enforce conventions: clear layers, strict validation, consistent errors, and reliable shutdown behavior.
Standard Error Response Format in Express
A consistent error format turns failures into a stable API contract, improving client behavior, monitoring, and incident response.
Request Validation Pattern (DTO + schema)
A repeatable validation pattern keeps handlers clean: parse unknown input into typed data, then run business logic only on trusted values.

API Design(13)

REST vs RPC: Picking the Right Style
REST and RPC are architectural styles with different trade-offs; choose based on evolvability, client diversity, and long-term system complexity.
Resource Modeling: URLs, nouns, and hierarchy
Resource modeling defines the shape of your API; good modeling reduces breaking changes and improves client predictability.
DTOs: Input/Output Shapes That Don’t Leak Internals
DTOs protect your domain model from external contracts; they decouple internal logic from public API representations.
API Versioning Without Chaos
API versioning is about controlling breaking changes; use it strategically to protect clients while evolving your system.
Pagination Patterns (cursor vs offset)
Pagination prevents performance collapse in large datasets; design it for consistency and stable ordering.
Filtering & Sorting Patterns
Filtering and sorting increase API flexibility but must be constrained to avoid expensive queries and abuse.
Consistent Error Responses (problem details style)
A consistent error format transforms failures into structured signals that clients and monitoring systems can reliably interpret.
Idempotency for Real APIs (POST without duplicates)
Idempotency ensures safe retries in distributed systems, especially for payments and resource creation endpoints.
OpenAPI/Swagger: Practical Documentation Workflow
OpenAPI formalizes your API contract, enabling documentation, client generation, and validation automation.
Auth Integration Points (where auth belongs)
Authentication integration must be designed at the API boundary, balancing security, usability, and performance.
Node APIs with Frontend Apps (CORS, cookies, tokens)
Frontend integration depends on predictable contracts, stable error formats, and clear pagination/filter semantics.
API Rate Limiting Strategy (Concept)
Rate limiting protects API availability and cost by preventing abusive or accidental traffic spikes.
Caching Basics for APIs (Where It Fits)
Caching reduces latency and cost; apply it deliberately at HTTP, application, or data layers.

Database Integration(12)

Connection Pooling
Connection pooling is mandatory in production Node.js apps; it protects your database from overload and stabilizes latency under concurrency.
Transactions
Transactions protect data integrity; use them intentionally to guarantee atomicity across multiple writes.
Raw SQL vs Query Builder
A query layer isolates raw SQL from the rest of your application, improving maintainability and testability.
Repository Pattern
The repository pattern abstracts persistence behind domain-focused interfaces, decoupling application logic from database technology.
Migration Strategy
Migrations manage schema evolution safely across environments; never change production schemas manually.
Indexing Basics
Indexing improves read performance but increases write cost; design indexes based on real query patterns.
N+1 Query Problem
The N+1 query problem silently destroys performance; batch and join intelligently to reduce database round trips.
When MongoDB Makes Sense
MongoDB is suitable for flexible schemas and document-centric workloads, but not every system benefits from NoSQL.
MongoDB Query Patterns
MongoDB patterns such as embedding vs referencing determine performance and scalability characteristics.
Preventing SQL Injection
SQL injection is prevented by parameterized queries; never concatenate user input into SQL strings.
DB Connection Lifecycle (Open/Close, Pool Hygiene)
Connection lifecycle management prevents leaks and ensures graceful shutdown in production environments.
Query Timeouts and Slow Query Diagnosis
Query timeouts protect the system from runaway queries and degraded database performance.

Auth Overview(8)

Errors & Logging(10)

Testing(8)

Performance(7)

Deployment(7)

Architecture Patterns(8)