Easy interview questions in Node.js & Express
How does Node.js handle thousands of connections on one thread?
This tests non-blocking I/O: Node.js runs one thread for an event loop while the OS handles sockets via epoll or IOCP, resuming callbacks when data arrives. Mention the thread pool for DNS and fs work. A red flag is claiming threads spawn per request.
dependencies vs devDependencies in package.json
Dependencies ship and run in production; devDependencies are only for development; omitted with npm install --production.
Resolving core vs relative module specifiers
'fs' is a built-in core module loaded by name with top priority; './my-file.js' is a relative path resolved from the current file.
The three states of a JavaScript Promise
Pending, fulfilled, rejected; settle is one-way and final; create with the executor calling resolve or reject, consume with then and catch.
fs.readFileSync vs fs.readFile
Sync blocks the event loop and returns directly, async takes a callback or promise, only sync is safe at startup.
Why use path.join over string concatenation
Path.join uses the correct OS separator, collapses duplicate slashes, normalizes . and .. segments.
Minimal HTTP server with the http module
CreateServer with a request listener, set status and Content-Type, end the response, call listen on 3000.
Minimal Express Hello World server
Import express, create an app, define app.get on the root sending a response, call app.listen on a port.
Serving static files in Express
App.use with express.static pointing at the public directory, files served relative to that root, often combined with an absolute path.
Query params vs route params in Express
Query string values via req.query.q, named path segments via req.params.id, query is optional, route params are part of the matched pattern.
What is Express middleware
Middleware are functions in a chain with req, res, next, they inspect or modify request and response, then call next to continue or send a response to end.
Parse JSON and URL-encoded bodies in Express
Express.json() for JSON, express.urlencoded() for form data, both registered via app.use().
Write a request-logging middleware in Express
Read req.method, log with a timestamp, then call next() to continue.
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.
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.
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.
Define a Mongoose schema and model
New mongoose.Schema with field options (type, required, default), then mongoose.model('Product', schema) to get a model.
Authentication versus authorization in Express
Authentication proves who you are, authorization decides what you may do, authentication happens first.
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.
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.
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