1.0.5 • Published 5 years ago

ts-api-controller-decorators v1.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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));
1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago