Skip to content
tezvyn:

Node.js & Express

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

70 bites

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

Easy everything in Node.js & Express

easy1 min read

How does NODE_ENV=production change Express behavior?

NODE_ENV is a convention signal, production disables verbose logging and enables caching.

easy1 min read

What does PM2 do for Node.js applications?

PM2 restarts crashed processes and manages multiple workers.

easy1 min read

Environment configuration and secrets management in Node.js?

Use environment variables, load from .env file (dev only), never commit secrets.

easy1 min read

How to add Socket.IO to an Express application?

Create HTTP server with express(), attach Socket.IO to it, listen on server not app, define event handlers.

easy1 min read

Socket.IO emit methods: socket, io, broadcast differences?

Socket.emit() sends to one client, broadcast.emit() to all except sender, io.emit() to all.

easy1 min read

HTTP request-response versus WebSocket connections?

HTTP is request-initiated, pull-based, client waits for response. WebSocket is persistent, bidirectional, either side sends data anytime.

easy1 min read

Purpose of the Node.js cluster module

Cluster forks worker processes sharing one listening port, so requests spread across CPU cores via the OS, raising throughput and adding resilience.

easy1 min read

What is a Node.js Stream and why use one

A stream processes data in chunks over time, so memory stays bounded and work starts before all data arrives; ideal for large files and network IO.

easy1 min read

Preventing XSS when rendering user content in templates

The risk is XSS; default to escaped interpolation (EJS <%= %>, Pug #{}) so HTML is encoded, and avoid raw output (<%- %>) for untrusted data.

easy1 min read

Purpose of Helmet middleware in Express

Helmet sets safe response headers like X-Content-Type-Options, HSTS, and CSP, mitigating MIME-sniffing, clickjacking, and protocol downgrade.

easy1 min read

Writing a basic Jest unit test

Import the function, group cases with describe, define each case with it or test, assert with expect and a matcher like toBe, covering normal and edge inputs.

easy1 min read

Unit, integration, and E2E tests explained

Unit tests isolate one function with dependencies mocked, integration tests exercise several units together (route plus DB), E2E tests drive the whole running system.

easy1 min read

Basic presence validation on a POST login route

Ensure the JSON body parser runs, destructure email and password from req.body, return 400 early if either is missing, then proceed.

easy1 min read

JWT structure and how the signature works

Name header, payload, and signature, note the first two are base64url-encoded not encrypted, explain the signature is computed over header and payload with a secret to detect tampering.

easy1 min read

Authentication versus authorization in Express

Authentication proves who you are, authorization decides what you may do, authentication happens first.

easy1 min read

Define a Mongoose schema and model

New mongoose.Schema with field options (type, required, default), then mongoose.model('Product', schema) to get a model.

easy1 min read

Status codes for successful POST and GET

201 Created for a successful POST (ideally with a Location header), 200 OK for a successful GET returning data.

easy1 min read

req.params vs req.query vs req.body in Express

Req.params holds named route segments, req.query holds the URL query string, req.body holds the parsed payload.

easy1 min read

Design an Express route to create a user

POST to a collection URL like /users, read the payload from req.body via express.json(), return 201 with the created resource.

easy1 min read

Write a request-logging middleware in Express

Read req.method, log with a timestamp, then call next() to continue.

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