Interview Q&A / Node.js

INTERVIEW Q&A · 68 QUESTIONS

Node.js interview questions

The event loop on the server, streams, modules and building APIs with Express.

  1. Write an Express middleware that checks a JWT and protects a route.

    Read the Bearer token from the Authorization header, verify it with jwt.verify, attach the claims to req.user and call next. On a missing or invalid token, respond 401 without calling next.

    BeginnerQuick answerCoding1 min read
  2. Write a Transform stream that converts incoming text to uppercase.

    Extend stream.Transform (or pass a transform function), call this.push with the changed chunk, and call the callback when done. Then pipe a readable into it and into a writable.

    IntermediateQuick answerCoding1 min read