whatisgithub

What is routing-controllers?

typestack/routing-controllers — explained in plain English

Analysis updated 2026-06-26

4,509TypeScriptAudience · developerComplexity · 3/5Setup · moderate

In one sentence

A TypeScript library that lets you define Express or Koa web server routes using classes and decorators instead of scattered function calls, with built-in validation and dependency injection.

Mindmap

mindmap
  root((routing-controllers))
    What it does
      Decorator routing
      Auto registration
      Request parsing
    Features
      Validation
      Middleware
      Auth guards
      Dependency injection
    Tech stack
      TypeScript
      Express
      Koa
      Node.js
    Use cases
      REST APIs
      Route grouping
      Type-safe routes
    Audience
      TypeScript devs
      Backend devs
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Organize an Express or Koa API into controller classes, each handling a group of related routes with decorators.

USE CASE 2

Automatically validate incoming JSON request bodies against TypeScript classes and return 400 errors for invalid data.

USE CASE 3

Protect API routes with authorization guards by adding a decorator that checks the user's role before running the handler.

USE CASE 4

Switch a Node.js API from Express to Koa with minimal code changes using the same decorator-based route definitions.

What is it built with?

TypeScriptNode.jsExpressKoanpm

How does it compare?

typestack/routing-controllerszdhxiong/mduiauth0/express-jwt
Stars4,5094,5094,510
LanguageTypeScriptTypeScriptTypeScript
Setup difficultymoderateeasyeasy
Complexity3/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires enabling experimentalDecorators and emitDecoratorMetadata in tsconfig.json before decorators will work.

So what is it?

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.

Copy-paste prompts

Prompt 1
Using routing-controllers with Express, create a UserController class with GET /users, POST /users, and DELETE /users/:id routes that automatically extract URL params and the request body.
Prompt 2
How do I add request body validation to a routing-controllers POST endpoint using class-validator so invalid data returns a 400 error?
Prompt 3
Set up routing-controllers with a dependency injection container so my controller classes automatically receive their service dependencies.
Prompt 4
Create an authorization guard in routing-controllers that checks a JWT token and blocks unauthenticated requests to protected routes.

Frequently asked questions

What is routing-controllers?

A TypeScript library that lets you define Express or Koa web server routes using classes and decorators instead of scattered function calls, with built-in validation and dependency injection.

What language is routing-controllers written in?

Mainly TypeScript. The stack also includes TypeScript, Node.js, Express.

How hard is routing-controllers to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is routing-controllers for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.