🌍 NodeJS · subject

NodeJS Networking Syllabus

Every chapter and topic of Networking examined in NodeJS — 2 chapters, 6 topics, plus 50 flashcards written against it.

2Chapters
6Topics
0Sub-topics
~5hEst. first pass
8%Of NodeJS
50Flashcards

Networking syllabus — full chapter and topic list

Expand any chapter to see its topics and sub-topics. This is the whole examinable outline for Networking in NodeJS, not a summary of it.

  1. HTTP Module

    3 topics
    • Creating a Server
    • Handling Requests and Responses
    • Routing
  2. WebSockets

    3 topics
    • Introduction to WebSockets
    • Implementing WebSocket Server
    • Real-time Communication

Networking flashcards for NodeJS

21 of 50 cards from the Networking deck — real questions with worked answers.

  1. Which core Node.js module is used to create an HTTP server, and how is it imported?

    The built-in `http` module. It is imported with `const http = require('http');` (CommonJS) or `import http from 'node:http';` (ESM). No installation is needed since it ships with Node.js.

  2. Write the minimal Node.js code to create an HTTP server that listens on port 3000.

    const http = require('http'); const server = http.createServer((req, res) => { res.end('Hello'); }); server.listen(3000);

  3. What two objects does the request-listener callback passed to http.createServer() receive, and what do they represent?

    It receives `(req, res)`: `req` is an http.IncomingMessage (the incoming request — a readable stream) and `res` is an http.ServerResponse (the outgoing response — a writable stream).

  4. What is the difference between res.write() and res.end() on an http.ServerResponse?

    res.write() sends a chunk of the response body and can be called multiple times to stream data. res.end() signals the response is complete; it optionally sends a final chunk and must be called to finish every response, or the client will hang.

  5. How do you set the HTTP status code and response headers before sending a body in Node's http module?

    Use `res.writeHead(statusCode, headersObject)`, e.g. `res.writeHead(200, { 'Content-Type': 'text/html' });`. Alternatively set `res.statusCode = 200;` and `res.setHeader('Content-Type', 'text/html');` individually before the first write.

  6. Why must Node.js request bodies be read from the stream in chunks rather than accessed directly?

    Because `req` is a readable stream — the body arrives asynchronously as data chunks. You collect it via the 'data' event (accumulating a Buffer) and process it on the 'end' event, since the full body is not available synchronously on the request object.

  7. Write the event-based pattern to collect a full request body in Node.js.

    let body = []; req.on('data', chunk => { body.push(chunk); }); req.on('end', () => { body = Buffer.concat(body).toString(); // parse/use body });

  8. Which two properties of the req (IncomingMessage) object identify what the client is asking for, and are the basis of routing?

    `req.url` (the request path, e.g. '/users') and `req.method` (the HTTP verb, e.g. 'GET' or 'POST'). Routing logic branches on these two values.

  9. What does server.listen(port, host, callback) do, and is it synchronous?

    It binds the server to the given port/host and starts accepting connections. It is asynchronous — the server does not begin listening immediately; the optional callback fires once the 'listening' event occurs and the server is ready.

  10. By default, is the Content-Type header set for a Node.js http response, and why does it matter?

    No default meaningful type is guaranteed for your content; you should explicitly set it. It matters because the client (browser) uses Content-Type to decide how to interpret the body — e.g. 'text/html' renders as a page, 'application/json' is parsed as JSON, 'text/plain' shows raw text.

  11. What is 'routing' in the context of a web server?

    Routing is the process of mapping an incoming request's URL path and HTTP method to the specific handler code that should produce the response. It directs different requests to different logic.

  12. Show a basic manual routing structure in vanilla Node.js using req.url and req.method.

    if (req.url === '/' && req.method === 'GET') { // home handler } else if (req.url === '/users' && req.method === 'POST') { // create user } else { res.writeHead(404); res.end('Not Found'); }

  13. What HTTP status code should a route handler return when no matching route is found?

    404 (Not Found). It signals to the client that the requested resource/path does not exist on the server.

  14. In Express.js, what is the general signature of a route definition?

    `app.METHOD(path, handler)`, e.g. `app.get('/users', (req, res) => { ... })`. METHOD is the lowercased HTTP verb (get, post, put, delete), path is the URL pattern, and handler is `(req, res, next) => {...}`.

  15. How do you define and read a route (path) parameter in Express?

    Declare it with a colon in the path, e.g. `app.get('/users/:id', ...)`, and read it from `req.params.id`. Route params capture dynamic segments of the URL.

  16. What is the difference between a route (path) parameter and a query string parameter?

    A route parameter is part of the URL path (e.g. /users/42 → req.params.id) and typically identifies a resource. A query parameter follows a '?' (e.g. /search?q=node → req.query.q) and typically carries optional filters/options.

  17. What is middleware in Express, and what three arguments does a middleware function receive?

    Middleware is a function that runs during the request-response cycle, able to inspect/modify req and res or end the response. It receives `(req, res, next)`; calling `next()` passes control to the next middleware/handler in the stack.

  18. What happens if an Express middleware neither sends a response nor calls next()?

    The request hangs — control is never passed on and no response is sent, so the client eventually times out. Every middleware must either end the response or call next().

  19. Compare the standard HTTP request-response model with WebSockets in terms of communication direction.

    HTTP is half-duplex/unidirectional per exchange and client-initiated: the client requests, the server responds, then the connection work ends. WebSockets are full-duplex and persistent: after the handshake, either side can send messages at any time over one open connection.

  20. What protocol identifiers (URI schemes) are used for WebSocket connections?

    `ws://` for an unencrypted WebSocket connection and `wss://` for an encrypted (TLS/SSL) WebSocket connection, analogous to http:// and https://.

  21. How is a WebSocket connection established? Describe the handshake.

    It begins as an HTTP request with an `Upgrade: websocket` and `Connection: Upgrade` header. If the server agrees, it responds with status 101 (Switching Protocols), and the underlying TCP connection is then upgraded from HTTP to the WebSocket protocol for full-duplex messaging.

See more Networking flashcards →

Planning Networking for NodeJS

Networking is about 8% of the NodeJS syllabus by topic count — 6 of 72 topics, spread over 2 chapters. At roughly 45 minutes per topic plus 12 minutes per sub-topic, a first pass runs to about 5 hours.

Work top-down: read the chapter, then tick topics off individually rather than marking the whole chapter done. Sub-topics are where silent gaps hide.

Networking (NodeJS) FAQ

What is in the NodeJS Networking syllabus?

Networking is split into 2 chapters — HTTP Module and WebSockets, containing 6 topics and 0 sub-topics in total.

How is Networking structured in the NodeJS syllabus?

2 chapters. Networking accounts for about 8% of the topics in the whole NodeJS syllabus (6 of 72).

How long should I spend on Networking for NodeJS?

Budget around 5 hours for a first pass through Networking — about 45 minutes per topic plus 12 minutes per sub-topic across its 6 topics. Add revision cycles on top.

Are there flashcards for NodeJS Networking?

Yes — a 50-card Networking deck. Sample cards are printed on this page, and the full deck is free in the Examius app with spaced repetition scheduling.