Use the express.Router class to create modular, mountable route handlers. A Router instance is a complete middleware and routing system; for this reason, it is often referred to as a “mini-app”.
You need to add a new set of user profile endpoints to an existing Express app. How would you use express.Router to keep the code organized?
If you forget to export the router from a module and import it in app.js, what will happen when the server starts?
How does mounting a router at '/api' affect the paths defined inside the router?
We have a feature where some routes need authentication middleware and others don't. How would you structure routers to apply auth only where needed without duplicating code?
During a code review you notice that a route handler is defined directly on app instead of a router, and the team is getting tangled dependencies. How would you refactor using express.Router, and what pitfalls might you watch for?
Our API versioning uses '/v1' and '/v2' prefixes. Explain how you would set up routers to support both versions and what issues could arise if you mount them incorrectly.
In a large codebase we’re seeing increased memory usage and slower cold starts because each route file imports the entire app. How would you redesign the routing layer with express.Router to improve startup time and maintainability?
We need to add per‑router error handling and logging while keeping global error handling consistent. How can you leverage express.Router to isolate concerns, and what trade‑offs does this introduce?
When scaling to many micro‑services, we want to share common route definitions across services. How would you use express.Router to enable reuse, and what challenges around versioning and dependency management might you face?
Our organization is moving from a monolithic Express server to a distributed set of services, but we still need a unified API gateway. How would you design the router hierarchy and module boundaries now to ease that migration, and what long‑term architectural considerations should you keep in mind?
Several teams maintain their own routers that are mounted on the same base path, leading to route collisions. How would you establish a routing contract or naming convention using express.Router to prevent conflicts at scale?
We plan to introduce a plugin system where third‑party modules can register routes dynamically at runtime. How would you structure the use of express.Router to safely isolate plugins and allow hot‑loading, and what security or performance implications must you address?