Skip to content
tezvyn:

Node.js & Express

Node.js, Express, Fastify, NestJS, Bun, Deno

70 bites

Test yourself: Top 30 intermediate Node.js & Express concepts questionsMultiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.

Intermediate concepts in Node.js & Express

intermediate2 min read

The Node.js Event Loop: Concurrency on a Single Thread

The Node.js event loop lets a single thread handle high concurrency by offloading I/O. It's ideal for web servers and APIs, but the footgun is that any long-running synchronous code will block the entire application, freezing all other requests.

intermediate2 min read

Event Loop vs Crypto Module

Node's crypto module offers both synchronous and asynchronous versions of CPU heavy operations like password hashing; the sync versions block the single threaded event loop, while async versions offload the work to a background thread pool.

JavaScript's Event Loop: Macrotasks & Microtasks
intermediate2 min read

JavaScript's Event Loop: Macrotasks & Microtasks

The JavaScript event loop processes tasks like setTimeout callbacks or user clicks from a macrotask queue. A single, long-running macrotask blocks all rendering and user input, freezing the UI. The footgun is assuming setTimeout(fn, 0) runs instantly.

intermediate2 min read

process.nextTick(): Cutting in Line on the Event Loop

process.nextTick() schedules a callback to run immediately after the current operation, before the event loop continues to timers or I/O. It's used for API consistency or error handling. The footgun is that overusing it can starve the event loop, blocking I/O.

intermediate2 min read

Node.js Streams: Processing Data in Chunks, Not Blobs

Think of streams as a data conveyor belt, processing large files or network data in chunks instead of loading it all into memory. Use them for file I/O or network requests.

intermediate2 min read

Node.js Child Processes: Escaping the Main Thread

A child process lets your Node.js app run external commands without blocking the event loop. Use it for CPU-intensive tasks like image processing or running system utilities. The footgun: using synchronous versions (execSync) will block your entire server.

intermediate2 min read

ES Modules in Node.js: The Modern `import` System

ES Modules bring the browser's import/export syntax to Node.js, replacing the classic require(). Use ESM for modern projects to get features like top-level await. The main footgun is that you can't use require(), __dirname, or __filename.

npx: Execute Packages Without Installing Them
intermediate2 min read

npx: Execute Packages Without Installing Them

npx runs Node.js tools without installing them globally, fetching the latest version on demand. Use it for one-off scaffolding like create-react-app or CI build scripts. The footgun: it may silently run a stale cached copy if you omit a version tag.

Environment Variables: Config Outside Your Code
intermediate2 min read

Environment Variables: Config Outside Your Code

Think of a .env file as a Post-it note of secrets for your app, kept separate from your codebase. Use it for API keys or database URLs that change between environments. The biggest mistake is committing your .env file to Git, exposing all your secrets.

Structuring Express Apps with Layered Architecture
intermediate2 min read

Structuring Express Apps with Layered Architecture

Think of your Express app as a three-story building: a web layer for HTTP traffic, a service layer for business logic, and a data layer for your database. This keeps code organized and testable.

Promise.then(): Each Call Returns a New Promise
intermediate2 min read

Promise.then(): Each Call Returns a New Promise

Each .then() call returns a new promise, letting you chain async tasks sequentially. This is key for multi-step operations like API calls. The footgun is attaching multiple .then()s to the original promise, which executes them in parallel, not in sequence.

Promise .catch(): Handling Rejections
intermediate2 min read

Promise .catch(): Handling Rejections

.catch() is the try...catch for promises, intercepting errors (rejections) in a chain. Use it at the end of a promise chain to handle failures from preceding steps, like a failed API call. The footgun: placing it mid-chain can swallow errors.

intermediate2 min read

Node.js util.promisify: From Callbacks to Promises

util.promisify converts callback-based functions into Promise-based ones, letting you use async/await with older Node.js APIs. It's a bridge for legacy code following the standard (err, value) callback pattern. The footgun: it fails on non-standard signatures.

Async/Await: Write Non-Blocking Code That Reads Synchronously
intermediate2 min read

Async/Await: Write Non-Blocking Code That Reads Synchronously

async/await lets you write non-blocking code that reads like simple, synchronous logic. It's used for network requests or database queries without freezing your app. The biggest footgun is using await inside a function you forgot to declare as async.

Promise.all(): Wait for Multiple Promises at Once
intermediate2 min read

Promise.all(): Wait for Multiple Promises at Once

Promise.all() runs multiple promises in parallel, resolving only when all have succeeded. It's for when you need data from several API endpoints to render a single component.

intermediate2 min read

path.join() vs. path.resolve(): Concatenation vs. Calculation

path.join() glues path segments together, while path.resolve() calculates an absolute path. Think string building vs. cd commands. Use join for relative paths and resolve for absolute ones.

intermediate2 min read

WHATWG URL API: Safely Parse URLs, Not Strings

Treat URLs as structured objects, not messy strings. The WHATWG URL API parses a URL into components like protocol and path, just like JSON.parse. Use it for incoming requests or outgoing API calls. The footgun is using the legacy url.parse().

Express Middleware: The Chain of Command for Requests
intermediate2 min read

Express Middleware: The Chain of Command for Requests

Express middleware is a chain of functions a request passes through. Each function can inspect, modify, or stop the request, useful for logging, auth, or body parsing.

express.Router: Group Routes into Modular Files
intermediate2 min read

express.Router: Group Routes into Modular Files

express.Router is a mini-app for your routes. It lets you group related endpoints (e.g., all /users/... routes) into their own file, keeping your main app.js clean. The footgun is forgetting to mount the router in the main app with app.use().

Scaffold an Express App with `express-generator`
intermediate2 min read

Scaffold an Express App with `express-generator`

The express-generator CLI is a blueprint for new Express apps, instantly creating a standard folder structure and boilerplate files. Use it to skip tedious setup of routes and views.

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles