🌍 NodeJS · flashcards

NodeJS ExpressJS Framework Flashcards

51 question-and-answer cards covering ExpressJS Framework as it is examined in NodeJS. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.

51Cards in deck
24Free preview
10Syllabus topics
~152Chars per answer
FreePrice

24 sample cards from the ExpressJS Framework deck

Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.

  1. Define 'routing' in ExpressJS.

    Routing is the mechanism of determining how an application responds to a client request to a particular endpoint, defined by a URL path and a specific HTTP method (GET, POST, etc.).

  2. What is the general form of a basic Express route definition?

    app.METHOD(PATH, HANDLER) — where METHOD is a lowercase HTTP method, PATH is the route path, and HANDLER is the (req, res) callback, e.g. app.get('/', (req, res) => res.send('Hi')).

  3. Which Express methods handle GET, POST, PUT, and DELETE requests?

    app.get(), app.post(), app.put(), and app.delete() respectively.

  4. What does app.all() do?

    It matches all HTTP methods for a given path, running the handler regardless of whether the request is GET, POST, PUT, DELETE, etc.

  5. How do you send a plain text vs a JSON response in a route handler?

    res.send('text') sends text/HTML; res.json({ key: 'value' }) sends a JSON response with Content-Type application/json.

  6. How can you attach multiple handlers to a single route?

    Pass several callbacks (or an array), e.g. app.get('/x', mw1, mw2, finalHandler); each calls next() to reach the following one.

  7. What are route parameters (named URL segments) in Express?

    Named segments in the path prefixed with a colon that capture dynamic values from the URL, e.g. '/users/:id' captures the id; captured values live in req.params.

  8. Given the route '/users/:id', how do you access the id value from a request to /users/42?

    Via req.params.id, which would be the string '42'.

  9. Can a route have multiple parameters? Give an example.

    Yes, e.g. '/users/:userId/books/:bookId' populates req.params.userId and req.params.bookId.

  10. How do route parameters (req.params) differ from query strings (req.query)?

    Route parameters are named parts of the URL path (/users/:id), while query strings are key=value pairs after '?' (/users?id=42) accessed via req.query; params identify a resource, query typically filters/options it.

  11. What is app.param() used for?

    It registers a callback that runs whenever a specific route parameter is present, useful for validating or pre-loading data (e.g. fetching a user by :id) before the route handlers execute.

  12. What is the Express Router module?

    express.Router() creates a modular, mountable mini-application (a 'mini-router') that can have its own routes and middleware, allowing route definitions to be split across files and mounted onto the main app.

  13. How do you create and export a router in a separate file?

    const router = express.Router(); router.get('/', handler); module.exports = router; — then mount it in the main app.

  14. How do you mount a router at a base path in the main app?

    app.use('/users', usersRouter); — all routes defined in usersRouter are prefixed with '/users'.

  15. Why is the Router module beneficial for larger applications?

    It promotes modularity and separation of concerns—grouping related routes and middleware together, keeping files small, and making the codebase easier to maintain and scale.

  16. Can a Router have its own middleware? How?

    Yes; via router.use(middleware), which applies the middleware only to routes handled by that router.

  17. What distinguishes error-handling middleware from regular middleware in Express?

    Error-handling middleware has four arguments: (err, req, res, next). Express recognizes it by the arity of four parameters and only invokes it when an error is passed.

  18. How do you trigger error-handling middleware from a regular middleware or route?

    By calling next(err) with an argument (an Error object); passing any argument to next() (other than the string 'route') signals Express to skip remaining normal middleware and jump to error handlers.

  19. Write the signature of a basic Express error-handling middleware that returns a 500.

    app.use((err, req, res, next) => { console.error(err.stack); res.status(500).send('Something broke!'); });

  20. Where should error-handling middleware be placed in the middleware stack, and why?

    Last, after all other app.use() and routes, so that errors passed via next(err) from any earlier middleware/route propagate down to it.

  21. In an async route handler, how do you forward a thrown error to Express error handling (pre-Express 5)?

    Catch it and call next(err), e.g. wrap in try/catch and 'catch (e) { next(e); }', or use a wrapper/async-handler, because Express 4 does not automatically catch rejected promises.

  22. What is centralized error handling in Express?

    A pattern where all errors are routed to a single, dedicated error-handling middleware (defined once, mounted last) that formats and sends consistent error responses, instead of duplicating error logic in every route.

  23. How is a custom Error class typically used in centralized error handling?

    You define a class (e.g. AppError) extending Error with properties like statusCode and message; routes throw/next() such errors, and the central handler reads err.statusCode and err.message to build a uniform response like res.status(err.statusCode).json({ error: err.message }).

  24. How do you handle unmatched routes (404) before the centralized error handler?

    Add a catch-all middleware after all routes, e.g. app.use((req, res, next) => next(new AppError('Not Found', 404))); which forwards a 404 error to the central error handler.

What this deck covers

The ExpressJS Framework deck follows the NodeJS ExpressJS Framework syllabus — 4 chapters and 10 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 12.8 cards per chapter.

Answers are written to be recallable, not just readable — averaging about 152 characters, which is long enough to carry the reasoning and short enough to say out loud.

A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.

ExpressJS Framework flashcards FAQ

How many ExpressJS Framework flashcards are in this NodeJS deck?

51 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.

Are these NodeJS flashcards free?

Yes. The preview here is free to read with no signup, and the full 51-card deck is free inside the Examius app.

What do the ExpressJS Framework cards cover?

They follow the NodeJS ExpressJS Framework syllabus — 4 chapters and 10 topics — so the questions track what is actually examinable.

How should I use these flashcards?

Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.