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 {
    return this.service.getPaginated(page, limit, fields, sort, q);
  }

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

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

  @Security('admin')
  @Delete('{id}')
  public async delete(id: string): Promise {
    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 {
    return this.service.create(body);
  }

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

  @Security('admin')
  @Delete('{id}')
  public async delete(id: string): Promise {
    return this.service.delete(id);
  }
}
github MakingSense / tsoa-api / src / controllers / UserController.ts View on Github external
public async getById(id: string): Promise {
    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 {
    return this.service.getPaginated(page, limit, fields, sort, q);
  }

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

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

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

tsoa

Build swagger-compliant REST APIs using TypeScript and Node

MIT
Latest version published 14 days ago

Package Health Score

95 / 100
Full package analysis