A route method is derived from one of the HTTP methods, and is attached to an instance of the express class.
You can use app.use() to apply middleware ot all routes irrespective of route path or method
You need to log every incoming request's method and URL in an Express app. How would you set that up so it runs for all routes?
If you add a middleware with app.use after defining some routes, which routes will it affect and why?
How would you apply a middleware only to routes that start with /api?
We have a feature where certain routes need authentication, but others are public. Walk me through how you'd structure the middleware to enforce this without duplicating code.
During a recent deployment, requests to /admin started returning 404 after we added a new global error‑handling middleware. How would you debug the issue?
Explain the trade‑offs between using app.use for a catch‑all middleware versus attaching it to each router instance.
Our service runs on multiple Node processes behind a load balancer, and we need to add a rate‑limiting middleware that works across all routes and processes. What design considerations would you address?
We want to conditionally apply a heavy logging middleware only in staging, but keep it off in production for performance. How would you implement this without restarting the server?
Describe how the order of route definitions and middleware affects response times and error propagation in a large Express codebase.
The company is migrating a monolithic Express app to a micro‑frontend architecture where each team owns its own router. How would you redesign the global middleware strategy to support independent deployment while preserving cross‑cutting concerns like auth and tracing?
Legacy code mixes app.use and router.use inconsistently, causing subtle bugs in error handling. Propose a long‑term refactoring plan that balances risk, testing, and team ownership.
At scale, we need to enforce security headers on every response without adding overhead. Discuss architectural options (e.g., proxy vs. middleware) and their impact on maintainability.