@nestjs/swagger#ApiBadGatewayResponse TypeScript Examples

The following examples show how to use @nestjs/swagger#ApiBadGatewayResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Enable users
   * @param ids User ID integers ?ids=1,2,3
   * @example DELETE /users/bulk/enable?ids=1,2,3
   */
  @ApiTags('Users batch operations')
  @ApiOperation({
    summary: 'Enable users - Batch',
    description: 'Enable users. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiQuery({ name: 'ids', required: true, type: 'string', example: '1,2,3' })
  @Patch('bulk/enable')
  async enableMany(@Query('ids', new ParseArrayPipe({ items: Number, separator: ',' })) ids: number[]) {
    return await this.service.enableMany(ids);
  }
Example #2
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Enable one user
   * @param ids User ID integer
   * @example DELETE /users/1/enable
   */
  @ApiTags('Users single operation')
  @ApiOperation({
    summary: 'Enable user - Batch',
    description: 'Enable user. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiParam({ name: 'id', required: true, type: 'number', example: '1' })
  @Patch(':id/enable')
  async enable(@Param('id') id: number) {
    return await this.service.enable(id);
  }
Example #3
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Disable user
   * @param ids User ID integer
   * @example DELETE /users/1/disable
   */
  @ApiTags('Users single operation')
  @ApiOperation({
    summary: 'Disable user - single',
    description: 'Disable user. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiParam({ name: 'id', required: true, type: 'number', example: '1' })
  @Patch(':id/disable')
  async disable(@Param('id') id: number) {
    return await this.service.disable(id);
  }
Example #4
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Restore softdeleted user
   * @param ids User ID integer
   * @example DELETE /users/1/restore
   */
  @ApiTags('Users single operation')
  @ApiOperation({
    summary: 'Restore user - Batch',
    description: 'Restore user. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiParam({ name: 'id', required: true, type: 'number', example: '1' })
  @Patch(':id/restore')
  async restore(@Param('id') id: number) {
    return await this.service.restore(id);
  }
Example #5
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Delete one (ATENTTION: PERMANENT DELETION)
   * @param id User ID integer
   */
  @ApiTags('Users single operation')
  @ApiOperation({
    summary: 'Hard delete  user - Batch',
    description: '(HARD DELETION) Delete user. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiParam({ name: 'id', required: true, type: 'number', example: '1' })
  @Delete(':id/hard')
  async hardDelete(@Param('id') id: number) {
    return await this.service.delete(id);
  }
Example #6
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Softdelete user (SOFT DELETION)
   * @param ids User ID integer
   * @example DELETE /users
   */
  @ApiTags('Users single operation')
  @ApiOperation({
    summary: 'Softdelete user - Batch',
    description: '(SOFT DELETION) Delete user. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiParam({ name: 'id', required: true, type: 'number', example: '1' })
  @Delete(':id')
  async delete(@Param('id') id: number) {
    return await this.service.softDelete(id);
  }
Example #7
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Update one - Single
   * @param dto Update User Form
   * @example PUT /users
   */
  @ApiTags('Users single operation')
  @ApiOperation({ summary: 'Update user - Single', description: 'Update user by Id. You have to provide an id in the body' })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiBadRequestResponse({ status: 400, description: 'You will prompt with an array with the validation issues' })
  @ApiBody({ required: true, type: UpdateUserDto })
  @Put()
  async updateOne(@Body() dto: UpdateUserDto) {
    return await this.service.update(dto);
  }
Example #8
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Get deleted users - Batch
   * @example GET /users/bulk?ids=1,2,3
   */
  @ApiTags('Users single operation')
  @ApiOperation({
    summary: 'Get Deleted Users by ids- Batch',
    description: 'Get users by Ids. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response', type: User })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiQuery({ name: 'ids', required: false, type: 'number', example: '1,2,3', explode: false })
  @Get('deleted')
  async getSoftdeletedUsers() {
    return await this.service.getDeletedUsers();
  }
Example #9
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Create User  - Single
   * @param dto User Form
   * @example POST /users
   */
  @ApiTags('Users single operation')
  @ApiOperation({ summary: 'Create User  - Single', description: 'Register an user, this can be public or privated.' })
  @ApiCreatedResponse({ status: 201, description: 'User created successfully', type: User })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiBadRequestResponse({ status: 400, description: 'You will prompt with the validation issues' })
  @ApiBody({ type: CreateUserDto })
  @Post()
  async createOne(@Body() dto: CreateUserDto): Promise<DataOutput<User>> {
    return { message: 'User created successfully', output: await this.service.create(dto) };
  }
Example #10
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Get users by ids - Batch
   * @param ids User ID integer Array
   * @example GET /users/bulk?ids=1,2,3
   */
  @ApiTags('Users batch operations')
  @ApiOperation({
    summary: 'Get Users by ids- Batch',
    description: 'Get Deleted users by Ids. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response', type: User })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiQuery({ name: 'ids', required: false, type: 'number', example: '1,2,3', explode: false })
  @Get('bulk/deleted')
  async getSoftdeletedUsersByIds(@Query('ids', new ParseArrayPipe({ items: Number, separator: ',' })) ids?: number[]) {
    return await this.service.getDeletedUsers(ids);
  }
Example #11
Source File: app.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Login user authentication
   * @param dto User Form
   * @example /auth/login
   */
  @ApiOperation({ summary: 'Login user authentication', description: 'In this way you will get the Token for Bearer authentication' })
  @ApiCreatedResponse({ status: 201, description: 'Login success, you will receive the "accessToken" there' })
  @ApiBadRequestResponse({ status: 400, description: 'Invalid credentials' })
  @ApiForbiddenResponse({ status: 403, description: 'Account is disabled, contact with administrator' })
  @ApiNotFoundResponse({ status: 404, description: 'Your account does not exist' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Login user authentication' })
  @ApiBody({ type: LoginDto })
  @UseGuards(LocalAuthGuard)
  @Post('auth/login')
  async login(@Request() req, @Body() loginDto: LoginDto) {
    return await this.authService.login(req.user);
  }
Example #12
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Disable users
   * @param ids User ID integers ?ids=1,2,3
   * @example DELETE /users/bulk/disable?ids=1,2,3
   */
  @ApiTags('Users batch operations')
  @ApiOperation({
    summary: 'Disable users - Batch',
    description: 'Disable users. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiQuery({ name: 'ids', required: true, type: 'string', example: '1,2,3' })
  @Patch('bulk/disable')
  async disableMany(@Query('ids', new ParseArrayPipe({ items: Number, separator: ',' })) ids: number[]) {
    return await this.service.disableMany(ids);
  }
Example #13
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Restore softdeleted users
   * @param ids User ID integers ?ids=1,2,3
   * @example DELETE /users/bulk/restore?ids=1,2,3
   */
  @ApiTags('Users batch operations')
  @ApiOperation({
    summary: 'Restore users - Batch',
    description: 'Restore users. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiQuery({ name: 'ids', required: true, type: 'string', example: '1,2,3' })
  @Patch('bulk/restore')
  async restoreMany(@Query('ids', new ParseArrayPipe({ items: Number, separator: ',' })) ids: number[]) {
    return await this.service.restoreMany(ids);
  }
Example #14
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Delete many (ATENTTION: PERMANENT DELETION)
   * @param ids User ID integers ?ids=1,2,3
   * @example DELETE /users?ids=1,2,3
   */
  @ApiTags('Users batch operations')
  @ApiOperation({
    summary: 'Hard delete users - Batch',
    description: '(HARD DELETION) Delete users. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiQuery({ name: 'ids', required: true, type: 'string', example: '1,2,3' })
  @Delete('bulk/hard')
  async hardDeleteMany(@Query('ids', new ParseArrayPipe({ items: Number, separator: ',' })) ids: number[]) {
    return await this.service.deleteMany(ids);
  }
Example #15
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Softdelete users (SOFT DELETION)
   * @param ids User ID integers ?ids=1,2,3
   * @example DELETE /users/bulk
   */
  @ApiTags('Users batch operations')
  @ApiOperation({
    summary: 'Softdelete users - Batch',
    description: '(SOFT DELETION) Delete users. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiBadRequestResponse({ status: 400, description: 'You will prompt with an array with the validation issues' })
  @ApiQuery({ name: 'ids', required: true, type: 'string', example: '1,2,3' })
  @Delete('bulk')
  async deleteMany(@Query('ids', new ParseArrayPipe({ items: Number, separator: ',' })) ids: number[]) {
    return await this.service.softDeleteMany(ids);
  }
Example #16
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Update many
   * @param dtos Update User Form including the ID insude
   * @example PUT /users/bulk
   */
  @ApiTags('Users batch operations')
  @ApiOperation({ summary: 'Update users - Batch', description: 'Update users. You have to provide an id each object inside an updateUserDTO' })
  @ApiOkResponse({ status: 200, description: 'Success response' })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiBadRequestResponse({ status: 400, description: 'You will prompt with an array with the validation issues' })
  @ApiBody({ required: true, type: [UpdateUserDto] })
  @Put('bulk')
  async updateMany(@Body(new ParseArrayPipe({ items: UpdateUserDto })) dtos: UpdateUserDto[]) {
    return await this.service.updateMany(dtos);
  }
Example #17
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Get users by ids - Batch
   * @param ids User ID integer Array
   * @example GET /users/bulk?ids=1,2,3
   */
  @ApiTags('Users batch operations')
  @ApiOperation({
    summary: 'Get Users by ids- Batch',
    description: 'Get users by Ids. You will have to provide a query param of ids separated by comas example: ?ids=1,2,3',
  })
  @ApiOkResponse({ status: 200, description: 'Success response', type: [User] })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiQuery({ name: 'ids', required: true, type: 'string', example: '1,2,3' })
  @Get('bulk')
  async getByIds(@Query('ids', new ParseArrayPipe({ items: Number, separator: ',' })) ids: number[]) {
    return await this.service.getByIds(ids);
  }
Example #18
Source File: users.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Create Users - Batch
   * @param dto User Form but in Array format
   * @example POST /users/bulk
   */
  @ApiTags('Users batch operations')
  @ApiOperation({ summary: 'Create Users - Batch', description: 'Register users in batch.' })
  @ApiCreatedResponse({ status: 201, description: 'Users created successfully', type: User })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Something happened' })
  @ApiBadRequestResponse({ status: 400, description: 'You will prompt with an array with the validation issues' })
  @ApiBody({ type: [CreateUserDto] })
  @Post('bulk')
  async createBulk(@Body(new ParseArrayPipe({ items: CreateUserDto })) dto: CreateUserDto[]): Promise<DataOutput<IUser[]>> {
    return { message: 'Users created successfully', output: await this.service.createBatch(dto) };
  }
Example #19
Source File: app.controller.ts    From nestjs-starter with MIT License 6 votes vote down vote up
/**
   * Create User - User Registration
   * @param dto User Form
   */
  @ApiOperation({
    summary: 'Get my profile',
    description: 'You will get prompt with your user data, keep in mind that you need to provide the Bearer Token for Authentication',
  })
  @ApiOkResponse({ status: 200, description: 'Success response', type: User })
  @ApiUnauthorizedResponse({ status: 401, description: 'Unauthorized' })
  @ApiBadGatewayResponse({ status: 502, description: 'Login user authentication' })
  @ApiBadRequestResponse({ status: 400, description: 'You will prompt with the validation issues' })
  @ApiBearerAuth()
  @UseGuards(JwtAuthGuard)
  @Get('auth/profile')
  async profile(@Request() req) {
    return { output: req.user };
  }