routing-controllers is a TypeScript library that lets you define the URL routes of a web server by writing plain classes with methods, rather than scattering route definitions across dozens of function calls. Each class represents a group of related routes, for example all user-related endpoints in one file, and each method in that class handles one kind of request. You attach small annotations called decorators to the class and its methods to tell the library what URL path each action responds to and what HTTP verb it uses (GET, POST, PUT, DELETE, and so on). The library works with two popular Node.js web frameworks: Express and Koa. You pick one, install it alongside routing-controllers, and the library registers all your routes automatically at startup. You do not have to wire up each route manually. It supports both frameworks with the same decorator syntax, so switching between them requires minimal changes. Beyond basic routing, the library can automatically pull values out of incoming requests and pass them into your method as function arguments. You can extract URL parameters, query string values, the request body, headers, cookies, and uploaded files, all by adding the appropriate decorator to each parameter. It can also automatically validate incoming data and convert raw string values into typed objects using companion libraries called class-validator and class-transformer. More advanced features include middleware support (code that runs before or after your handler), interceptors (code that can modify the response), authorization helpers that let you protect routes behind a login check, and integration with dependency injection containers so the library can automatically construct your controller classes with the services they need. Controllers can also inherit from one another to share common behavior. The project is maintained under the TypeStack organization, which also publishes related libraries like TypeORM and class-validator. Installation is done through npm and requires a couple of TypeScript compiler settings to be turned on. The full README is longer than what was shown.
← typestack on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.