What problem does it solve?
This guide standardizes how HTTP routes are defined, ordered, and protected so API endpoints behave predictably and securely across the codebase, preventing route collisions and inconsistent access control.
Core Features & Use Cases
- Clear route file naming and export conventions to simplify registration and discovery.
- Middleware stacking patterns and examples for authentication, role checks, optional auth, and signature verification.
- Parameter and nested-resource syntax guidance plus a strict rule requiring both :id and /code/:code route variants for entities with a code field to support short-shareable identifiers.
- Route ordering strategy to ensure specific routes are matched before generic patterns and a central index that aggregates routes in the correct order.
Quick Start
Create a new [entity]Routes file following the naming convention, register it in routes/index.ts placing specific routes before generic ones, and add both :id and /code/:code variants when the entity has a code field.