Key takeaways
- Explains why Node is non-blocking with a simple waiter example and an event loop diagram.
- Shows the exact print order of sync code, promises and timers, a favourite interview question.
- Builds REST APIs first in memory, then with MongoDB and Mongoose, then with JWT login.
- Includes a security table: helmet, exact CORS origin, rate limiting, input validation and NoSQL injection.
About these Node.js notes
Node.js runs JavaScript outside the browser, on your computer or a server, using the V8 engine. It is event-driven and non-blocking: like one waiter serving many tables, it does not wait for a slow file or database call but takes the next request and comes back when the result is ready. That makes it a strong fit for APIs, chat apps and streaming. These notes start from the runtime itself, then build an API with Express and MongoDB and finish with authentication, security and deployment.
Please note: these are original Uncodemy study notes written in a handwritten style. They are not official documentation of the OpenJS Foundation, Express or MongoDB. Tools and versions change, so check the official docs linked below when something behaves differently on your machine.
What's inside the Node.js notes
The PDF has 12 numbered sections across 11 pages. Here is what each one covers.
Start with the runtime
What Node.js is, the client to Express to Mongoose to MongoDB flow, browser JavaScript versus Node.js, installing the LTS version, node --watch, and the weak spot of heavy CPU work.
Modules and npm
CommonJS versus ES modules, sharing a function between files, the main npm commands, package.json scripts, node_modules and package-lock.json.
Core modules and files
A table of fs, path, http, os, events, crypto and process, reading and writing files with fs/promises, a server with only the http module, and streams for big files.
Async code and events
Callbacks, promises and async/await, an event loop diagram, Promise.all, the print order of sync code, microtasks and timers, and EventEmitter.
Express basics
A first Express server, the useful parts of req and res, params and query, and the most common beginner bug: a missing express.json().
Routing and middleware
What middleware is (with an airport security example), a logger middleware, common middleware such as cors, helmet, morgan and rate limiting, and splitting routes with Router.
Building REST APIs
Routes, actions and success codes, an in-memory CRUD example, a status code table, versioning, pagination and testing with Postman, Thunder Client or curl.
MongoDB basics
Documents and collections, SQL terms mapped to MongoDB, CRUD in mongosh, query and update operators, embedding versus referencing, indexes and an aggregation pipeline.
Mongoose and CRUD
Connecting to the database, a schema with validation, the main model methods, Express routes with Mongoose, and linking collections with ref and populate.
Authentication and tokens
Authentication versus authorization, hashing with bcrypt, creating a JWT, an auth middleware and keeping JWT_SECRET out of the code.
Errors, security and config
Loading .env with --env-file or dotenv, a 404 and global error handler, Express 4 versus Express 5 async errors, a security checklist, a clean folder layout and deployment with Render or Railway.
Projects and practice
Six projects (notes API, URL shortener, auth system, blog API, e-commerce backend, chat app), a common mistakes table and ten practice questions.
How this differs from our other Node.js pages
The Node.js Interview Questions PDF is a set of questions with model answers for interview practice. These notes teach the topics from the start with runnable examples, so read them first and use the interview PDF to test yourself. To connect your API to a React frontend and build a full app with login, continue with the MERN Stack Notes PDF.
How to study Node.js with these notes
Run every example in the notes on your own machine. Node concepts like the event loop only click when you see the output yourself.
- Install the Node LTS, check node -v and npm -v, and run the first examples with node --watch.
- Predict the output of the event loop example before running it, then explain why it prints 1, 4, 3, 2.
- Build the in-memory todo API first, then replace the array with MongoDB and Mongoose.
- Add bcrypt, JWT and the auth middleware last, and test protected routes in Postman with a Bearer token.
Keep a notes file of every error message you hit and how you fixed it. The common mistakes table on the last page is a good starting list.
Concepts and code patterns to memorise
- Event loop order: normal code, then promise callbacks (microtasks), then timers and I/O callbacks.
- Middleware signature (req, res, next) and why order matters.
- req.params for URL parts, req.query for ?page=, req.body for JSON (needs express.json()).
- SQL to MongoDB: table is collection, row is document, column is field, primary key is _id.
- Status codes: 200, 201, 204 for success; 400, 401, 403, 404, 409 and 500 for errors.
Common mistakes beginners make
- req.body is undefined because express.json() was not added before the routes.
- Forgetting to await database calls.
- Using blocking sync code such as readFileSync inside request handlers.
- Keeping secrets in the code instead of .env and .gitignore.
- Sending the password hash back in responses.
- CORS errors from not allowing the frontend origin.
Interview focus: Node.js topics asked most
Node.js interviews usually start with how the runtime works, then move to Express, databases and API security.
- Why Node is non-blocking and how the event loop works.
- CommonJS versus ES modules.
- Express middleware, routing and error handling.
- PUT versus PATCH and the right status codes.
- SQL versus MongoDB, Mongoose schemas, JWT and securing an API.
Typical interview and viva questions
- What is Node.js and why is it called non-blocking?
- Explain the event loop with an example.
- Compare CommonJS and ES modules.
- What is middleware in Express? Write one.
- What is the difference between PUT and PATCH, and which status codes do create and delete return?
- How does JWT authentication work in an Express API?
- How do you secure an Express API?
Practise writing a small middleware and an auth check by hand, because many interviews include a short live coding task.
A 7-day plan with the Node.js notes
- Day 1: Start with the runtime, modules and npm. Set up a project with ES modules and scripts.
- Day 2: Core modules and files, async code and events. Run the file, http server and event loop examples.
- Day 3: Express basics, routing and middleware. Build a server with a logger and split routes.
- Day 4: Building REST APIs. Write the in-memory todo CRUD and test it in Postman.
- Day 5: MongoDB basics, Mongoose and CRUD. Move the API to MongoDB Atlas or a local database.
- Day 6: Authentication and tokens. Add register, login and an auth middleware.
- Day 7: Errors, security and config. Add the error handlers and security steps, deploy, then answer the ten practice questions from memory.
Next, build one project from the list, such as the URL shortener or blog API, and then connect it to a React frontend.
Who these notes are for
- Students who know JavaScript and want to build backends and APIs.
- Freshers preparing for Node.js, backend or MERN interviews.
- Frontend developers who want to write their own APIs.
- Testers who test Node APIs and want to understand the code.
You should know basic JavaScript, including functions, objects and promises. For the React side and a full app with login, continue with the MERN notes linked below.
Download Node.js Notes PDF
Node.js Notes PDF: Express, REST APIs, MongoDB
The PDF carries the same content as this page in a clean, print-ready layout, so you can read it offline and keep it for revision.
11 pages · 147 KB · PDF · Updated 5 Nov 2026