A decorator-based REST controller library for Express v5 (≥20.0.0) that provides a modernized, TypeScript-first alternative to legacy routing-controllers. Current version is 1.0.0-rc.2 — release candidate, still in development phase. Key differentiators: native async error handling leveraging Express 5, method-level input schemas using Standard Schema (validator-agnostic: supports Zod, Valibot, ArkType without adapters), and full TypeScript decorators with experimentalDecorators/emitDecoratorMetadata. No CommonJS or browser support. Requires `reflect-metadata` at runtime.
npm install express-rest-decoratorsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up a basic Express server with a JSON controller defining two endpoints: GET /users/:id and POST /users, using Zod for input validation.
Ensure your project uses Express ^5.1.0. Downgrading to v4 will cause runtime errors in async handlers.
Migrate from routing-controllers by moving parameter decorators to the method decorator's schema options and restructuring the handler signature.
Ensure tsconfig.json has experimentalDecorators: true and emitDecoratorMetadata: true. Also set useDefineForClassFields: false to avoid class field initialization issues.
Add `import 'reflect-metadata'` at the very top of your app's entry file (e.g., index.ts or server.ts). Do not import it multiple times.
Use a supported library: Zod >=3.23, Valibot >=0.30, ArkType >=1.0. Ensure the version implements the Standard Schema interface.
Add `import 'reflect-metadata'` as the first import in your entry file.
Use `import { JsonController } from 'express-rest-decorators'` instead of `import JsonController from 'express-rest-decorators'`.Add `"experimentalDecorators": true` and `"emitDecoratorMetadata": true` to tsconfig.json, then compile with tsc before running.
Double-check the route path and schema definition. Ensure middleware like express.json() is applied before useExpressControllers (for body parsing) and that the request has proper Content-Type.
Install express as a regular dependency: `npm install express` or `pnpm add express`. Ensure it's listed in dependencies, not devDependencies.