ts-api-controller-decorators
v1.0.5
Published
[npm](https://www.npmjs.com/package/ts-api-controller-decorators)
Downloads
3
Readme
ts-api-controller-decorators
Example:
- Decorate controller:
@Controller({baseUrl: '/api/foo'})
export class FooController {
constructor(private readonly service: FooService) {
}
@Get()
async getFoos(): Promise<Foo[]> {
return await this.service.getAll();
}
@Get(":id")
async getFoo(req): Promise<Foo> {
return await this.service.get(req.params.id);
}
...
}
- Register controller: Fastify example:
const server = Fastify({logger: true});
registerController(controller, route => server.route(route));