Node & Express
24 questions · 5 output questions · 5 challenges · 3 mocks
Node Fundamentals
CommonJS vs ES Modules (ESM)
What is the difference between CommonJS and ES Modules in Node.js, and how do you enable each one?
The Event Loop in Node.js
What is the event loop in Node.js, what are its phases, and how does it differ from the browser's event loop?
Non-blocking I/O
What is the difference between blocking and non-blocking I/O in Node.js, and why should you never block the event loop in a server?
process.nextTick and microtasks
What is the execution order between `process.nextTick`, promises (`.then`), `setImmediate` and `setTimeout` in Node.js?
Environment variables
What are environment variables in Node.js, how do you read them, and why should you not hardcode secrets in the code?
What is Node.js
What is Node.js and how does it manage to serve many requests at the same time with a single thread?
Modules & npm
Dependencies vs devDependencies
What is the difference between `dependencies` and `devDependencies` in `package.json`? Why does the distinction matter?
The package.json file
What is the `package.json` for, and what do its most important fields like `scripts`, `main`, and `type` do?
The CommonJS module system (require)
What does `require` do internally in CommonJS? What happens if you `require` the same file twice?
Semantic versioning (semver) and package-lock.json
What does semantic versioning (`major.minor.patch`) mean, and what is the difference between `^` and `~` in the versions in `package.json`?
Express Fundamentals
params, query, and body
What is the difference between `req.params`, `req.query`, and `req.body` in Express?
What is Express
What is Express and what problem does it solve on top of Node's `http` module?
Request and Response in Express
What information do the `req` and `res` objects carry in Express, and what are the most common response methods?
Routing in Express
What is routing in Express and how do you define routes with dynamic parameters like `/usuarios/:id`?
Middleware
Error handling in async handlers in Express
In Express 4, what happens if an `async` handler throws an error or its promise is rejected, and how do you handle it correctly?
Error-handling middleware in Express
How does error-handling middleware work in Express and how does the framework recognize it?
Middleware order in Express
Why does the order in which you register middleware and routes in Express matter?
What a middleware is in Express
What is a middleware in Express and how does it work within a request's lifecycle?
REST APIs
HTTP status codes
What families of HTTP status codes exist, and which code would you use for each CRUD operation?
CRUD and HTTP verbs
How do CRUD operations map to HTTP verbs, and what does it mean for a verb to be idempotent?
Structure of an Express project
How would you organize an Express project into layers, and why separate routes, controllers and services?
REST principles
What is a REST API and what are its fundamental principles?
Basic security in an Express API
What basic security measures would you apply in a REST API with Express?
Data validation
Why do you have to validate the client's input, and what is the difference between responding 400 and 422?
Coding challenges
create an asyncHandler wrapper and a centralized error-handling middleware.
javascript
build a CRUD REST API for "tareas" backed by an in-memory array.
javascript
create a minimal Express server with a GET / route.
javascript
write a middleware that logs the method, url, and response time.
javascript
an endpoint that filters and paginates an array based on the query params.
javascript
What does this code print?
What does it print? #001
Node's event loop, ordering of nextTick, Promise, setTimeout, setImmediate.
What does it print? #002
module caching in Node (require always returns the same instance).
What does it print? #003
async/await and execution order (what runs synchronously and what runs asynchronously).
What does it print? #004
Node's event loop, setTimeout(0) vs setImmediate inside an I/O callback.
What does it print? #005
closures and scope (var vs let) in asynchronous callbacks, like those in a server.