Skip to content
tezvyn:

Node.js & Express

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

135 bites

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

Intermediate everything in Node.js & Express, page 6

intermediate2 min read

Supertest: Test Node.js APIs Without the Boilerplate

Supertest lets you test your Node.js API without running a separate server. Use it in Jest or Mocha to make requests to your routes and assert on responses. The footgun: since it's in-process, state can leak between tests if not reset properly.

intermediate2 min read

Never Trust User Input: The Validation Mindset

Treat all incoming data as hostile until proven otherwise. Input validation ensures only properly formed data enters your system, protecting against errors and attacks. It applies to user forms, APIs, and partner feeds.

intermediate2 min read

Joi: Declarative Schemas for Data Validation

Joi lets you describe your data's shape with a readable schema instead of writing manual validation logic. It's used to validate API request bodies or config files.

The Refresh Token Pattern: Stay Logged In Securely
intermediate2 min read

The Refresh Token Pattern: Stay Logged In Securely

A refresh token is like a key to a key-making machine; it mints new access tokens without re-prompting the user. This pattern keeps users logged in to web and mobile apps. The footgun: a leaked refresh token can grant an attacker indefinite access.

Passport.js: The Local Strategy for Username/Password Auth
intermediate2 min read

Passport.js: The Local Strategy for Username/Password Auth

Passport's Local Strategy is the bouncer for traditional username/password logins in Node.js. You provide the logic to verify credentials against your database, and Passport handles the session management.

intermediate2 min read

Sequelize Migrations: Version Control for Your Database

Think of Sequelize migrations as Git for your database schema. Each file is a commit describing how to apply (up) and revert (down) a change. Use them to evolve your schema reliably across environments. The footgun: never edit the DB directly.

Mongoose Validation: Your Schema's Built-in Guard
intermediate2 min read

Mongoose Validation: Your Schema's Built-in Guard

Mongoose validation is a guard at the application layer, ensuring data conforms to schema rules before hitting the database. Use it for required fields, lengths, and ranges. The unique option is for database indexes, not a Mongoose validation rule.

Mongoose Middleware (Hooks): Intercepting Database Operations
intermediate2 min read

Mongoose Middleware (Hooks): Intercepting Database Operations

Mongoose middleware (hooks) lets you intercept database operations. Think of them as "before" or "after" scripts for actions like save or find. Use them to hash passwords before saving a user.

intermediate2 min read

Sequelize Associations: Who Holds the Foreign Key?

Think of Sequelize associations as rules for foreign keys. A.belongsTo(B) means A holds the bId foreign key. A.hasOne(B) or A.hasMany(B) means B holds the aId key. The footgun is mixing these up, which breaks your database schema and queries.

API Pagination: Serving Big Datasets in Chunks
intermediate2 min read

API Pagination: Serving Big Datasets in Chunks

API pagination breaks large result sets into smaller chunks to prevent server overload. It's essential for any endpoint returning many records, like a list of users or products.

API Versioning: Managing Change Without Breaking Clients
intermediate2 min read

API Versioning: Managing Change Without Breaking Clients

API versioning lets you evolve an API without breaking existing clients. It's essential for public APIs or services with multiple frontends that can't update in lockstep. The footgun is delaying versioning, forcing a painful migration on early users.

Mongoose: Schemas are Blueprints, Models are Factories
intermediate2 min read

Mongoose: Schemas are Blueprints, Models are Factories

A Mongoose Schema is the blueprint for your data, defining its shape and types. A Model is the factory that uses this blueprint to create, query, and save documents in MongoDB. The common footgun is trying to query the blueprint instead of the factory.

cookie-parser: From Header String to Usable Object
intermediate2 min read

cookie-parser: From Header String to Usable Object

The cookie-parser middleware translates the raw Cookie header string into a usable req.cookies object. It's used in Express apps to read session IDs or user preferences.

Morgan: One-Line Request Logging for Express
intermediate2 min read

Morgan: One-Line Request Logging for Express

Morgan is a plug-and-play stenographer for your Express app, automatically logging every incoming HTTP request. Use its predefined formats for quick debugging or create custom formats for production access logs.

intermediate2 min read

Helmet.js: Secure Express Apps with HTTP Headers

Helmet.js adds a security layer to Express apps by setting crucial HTTP headers. Use it in any public-facing Node app to prevent common attacks like XSS. The footgun: its default Content-Security-Policy is strict and requires app-specific configuration.

CORS Middleware: Unlocking Cross-Origin Requests in Express
intermediate2 min read

CORS Middleware: Unlocking Cross-Origin Requests in Express

The cors middleware tells browsers which external websites can read your Express API's responses. Use it when a frontend on one domain needs to fetch data from your API on another.

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.

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().

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.

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().

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