ts-api-controller-decorators
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

ts-api-controller-decorators

npm

Example:

  1. 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);
  }
  
  ...
}
  1. Register controller: Fastify example:
    const server = Fastify({logger: true});
    registerController(controller, route => server.route(route));

Readme

Keywords

none

Package Sidebar

Install

npm i ts-api-controller-decorators

Weekly Downloads

3

Version

1.0.5

License

MIT

Unpacked Size

168 kB

Total Files

14

Last publish

Collaborators

  • dmansurov83