All jobs / Backend developer / Backend Languages
Backend developer interview question · 0–1 years
The interviewer asks: “What does a good Express (or Fastify) route handler look like?” Strongest answer?
The strongest answer
Read the request, validate, await the service, send a status and JSON. Don't swallow errors — pass them to the error middleware so failures become a safe 5xx.
Why it works
Exactly. Async I/O, validation, and a single error path. Unhandled promise rejections are 500s you never logged.
What a good answer covers
- Validate, await, respond, don't swallow.
- Use error middleware for failures.
- Don't block the event loop.
- Never eval request input.
Answers that fall short
- Close, but not the strongest: app.get('/users', async (req, res) => { const rows = await db.query(...); res.json(rows); })
The happy path is fine as a sketch. Missing validation, mapping and error handling is how you leak schema and hang on thrown errors. - Weak: Handlers can stay synchronous; Node will wait for the database.
A sync handler that blocks on I/O blocks the event loop for everyone. Await the I/O; don't pretend it's sync. - Red flag: eval(req.body.code) to support a scriptable admin API.
eval on request input is remote code execution. There is no “admin” excuse.
Who gets asked this
More Backend Languages questions
- The interviewer asks: “How should a FastAPI path operation be structured?” Strongest answer?
- A Node service that normally answers in 20 ms starts timing out on every endpoint whenever one particular…
- def add(item, bag=[]): bag.append(item); return bag — you call add(1) then add(2). What comes back the second…
- You pass a class instance and a struct to a method and both are modified inside. What does the caller see?
- When would you choose a tuple over a list?
- What is the most common cause of a NullReferenceException in a new codebase?
- What is the difference between == and is?
- When do you use an array rather than a List<T>?