How to use the tsoa.Security function in tsoa

To help you get started, we’ve selected a few tsoa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MakingSense / tsoa-api / src / controllers / UserController.ts View on Github external
@Query('limit') limit: number,
    @Query('fields') fields?: string,
    @Query('sort') sort?: string,
    @Query('q') q?: string): Promise<IPaginationModel> {
    return this.service.getPaginated(page, limit, fields, sort, q);
  }

  @Response(400, 'Bad request')
  @Security('admin')
  @Post()
  public async create(@Body() body: IUserModel): Promise<IUserModel> {
    return this.service.create(body);
  }

  @Response(400, 'Bad request')
  @Security('admin')
  @Put('{id}')
  public async update(id: string, @Body() body: IUserModel): Promise<IUserModel> {
    return this.service.update(id, body);
  }

  @Security('admin')
  @Delete('{id}')
  public async delete(id: string): Promise<void> {
    return this.service.delete(id);
  }
}
github MakingSense / tsoa-api / src / controllers / UserController.ts View on Github external
@Response(400, 'Bad request')
  @Security('admin')
  @Post()
  public async create(@Body() body: IUserModel): Promise<IUserModel> {
    return this.service.create(body);
  }

  @Response(400, 'Bad request')
  @Security('admin')
  @Put('{id}')
  public async update(id: string, @Body() body: IUserModel): Promise<IUserModel> {
    return this.service.update(id, body);
  }

  @Security('admin')
  @Delete('{id}')
  public async delete(id: string): Promise<void> {
    return this.service.delete(id);
  }
}
github MakingSense / tsoa-api / src / controllers / UserController.ts View on Github external
public async getById(id: string): Promise<IUserModel> {
    return this.service.getById(id);
  }

  @Get()
  public async getPaginated(
    @Query('page') page: number,
    @Query('limit') limit: number,
    @Query('fields') fields?: string,
    @Query('sort') sort?: string,
    @Query('q') q?: string): Promise<IPaginationModel> {
    return this.service.getPaginated(page, limit, fields, sort, q);
  }

  @Response(400, 'Bad request')
  @Security('admin')
  @Post()
  public async create(@Body() body: IUserModel): Promise<IUserModel> {
    return this.service.create(body);
  }

  @Response(400, 'Bad request')
  @Security('admin')
  @Put('{id}')
  public async update(id: string, @Body() body: IUserModel): Promise<IUserModel> {
    return this.service.update(id, body);
  }

  @Security('admin')
  @Delete('{id}')
  public async delete(id: string): Promise<void> {
    return this.service.delete(id);