1.0.5 • Published 7 years ago

ts-api-controller-decorators v1.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
7 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

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago