@nestjs/swagger#ApiNoContentResponse TypeScript Examples
The following examples show how to use
@nestjs/swagger#ApiNoContentResponse.
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: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiInternalServerErrorResponse({ description: '500. InternalServerError' })
@ApiBearerAuth()
@Delete('logout-all')
@UseGuards(RolesGuard)
@Roles(RolesEnum.admin)
@HttpCode(HttpStatus.NO_CONTENT)
async logoutAll(): Promise<{}> {
return this.authService.deleteAllTokens();
}
Example #2
Source File: transaction.controller.ts From bank-server with MIT License | 6 votes |
@Patch('confirm')
@HttpCode(HttpStatus.NO_CONTENT)
@Roles(RoleType.USER, RoleType.ADMIN, RoleType.ROOT)
@ApiNoContentResponse({
description: 'confirm transfer',
})
async confirmTransaction(
@AuthUser() user: UserEntity,
@Body() confirmTransactionDto: ConfirmTransactionDto,
): Promise<void> {
await this._transactionService.confirmTransaction(
user,
confirmTransactionDto,
);
}
Example #3
Source File: auth.controller.ts From bank-server with MIT License | 6 votes |
@Patch('password/reset')
@ApiBearerAuth()
@UseGuards(JwtResetPasswordGuard)
@HttpCode(HttpStatus.NO_CONTENT)
@ApiNoContentResponse({
status: HttpStatus.NO_CONTENT,
description: 'Successfully reseted password',
})
@Transactional()
async resetPassword(
@Body() { password }: UserResetPasswordDto,
@Req() { user },
) {
return this._authService.handleResetPassword(password, user);
}
Example #4
Source File: auth.controller.ts From bank-server with MIT License | 6 votes |
@Post('password/forget')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiNoContentResponse({
status: HttpStatus.NO_CONTENT,
description: 'Successfully token created',
})
async forgetPassword(
@Body() userForgottenPasswordDto: UserForgottenPasswordDto,
): Promise<void> {
await this._authService.handleForgottenPassword(userForgottenPasswordDto);
}
Example #5
Source File: auth.controller.ts From bank-server with MIT License | 6 votes |
@Patch('logout')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiNoContentResponse({
description: 'Successfully Logout',
})
@UseGuards(AuthGuard, RolesGuard)
@UseInterceptors(AuthUserInterceptor)
@ApiBearerAuth()
@Roles(RoleType.USER, RoleType.ADMIN, RoleType.ROOT)
async userLogout(@AuthUser() user: UserEntity): Promise<void> {
await this._userAuthService.updateLastLogoutDate(user.userAuth);
}
Example #6
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiBearerAuth()
@Delete('logout-all')
@UseGuards(RolesGuard)
@Roles(RolesEnum.admin)
@HttpCode(HttpStatus.NO_CONTENT)
async logoutAll(): Promise<{}> {
return this.authService.deleteAllTokens();
}
Example #7
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'No content. 204',
})
@ApiNotFoundResponse({
schema: {
type: 'object',
example: {
message: 'string',
error: 'Not Found',
},
},
description: 'User was not found',
})
@HttpCode(HttpStatus.NO_CONTENT)
@Get('verify/:token')
async verifyUser(@Param('token') token: string): Promise<{} | never> {
const { id } = await this.authService.verifyEmailVerToken(
token,
this.configService.get<string>('ACCESS_TOKEN') || '<%= config.accessTokenSecret %>',
);
const foundUser = await this.usersService.getUnverifiedUserById(id);
if (!foundUser) {
throw new NotFoundException('The user does not exist');
}
return this.usersService.update(foundUser.id, { verified: true });
}
Example #8
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiBearerAuth()
@Delete('logout-all')
@Auth(RolesEnum.admin)
@HttpCode(HttpStatus.NO_CONTENT)
async logoutAll(): Promise<{}> {
return this.authService.deleteAllTokens();
}
Example #9
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'No content. 204',
})
@ApiNotFoundResponse({
schema: {
type: 'object',
example: {
message: 'string',
error: 'Not Found',
},
},
description: 'User was not found',
})
@HttpCode(HttpStatus.NO_CONTENT)
@Get('verify/:token')
async verifyUser(@Param('token') token: string): Promise<User | null> {
const { id } = await this.authService.verifyEmailVerToken(
token,
this.configService.get<string>('ACCESS_TOKEN') || '<%= config.accessTokenSecret %>',
);
const foundUser = await this.usersService.getUnverifiedUserById(id) as UserDocument;
if (!foundUser) {
throw new NotFoundException('The user does not exist');
}
return this.usersService.update(foundUser._id, { verified: true });
}
Example #10
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiInternalServerErrorResponse({ description: '500. InternalServerError' })
@ApiBearerAuth()
@Delete('logout-all')
@UseGuards(RolesGuard)
@Roles(RolesEnum.admin)
@HttpCode(HttpStatus.NO_CONTENT)
async logoutAll(): Promise<{}> {
return this.authService.deleteAllTokens();
}
Example #11
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'No content. 204',
})
@ApiNotFoundResponse({
schema: {
type: 'object',
example: {
message: 'string',
error: 'Not Found',
},
},
description: 'User was not found',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@HttpCode(HttpStatus.NO_CONTENT)
@Put('verify')
async verifyUser(@Body() verifyUserDto: VerifyUserDto): Promise<SuccessResponseInterface | never> {
const foundUser = await this.usersService.getUnverifiedUserByEmail(
verifyUserDto.email,
);
if (!foundUser) {
throw new NotFoundException('The user does not exist');
}
return ResponseUtils.success(
'users',
await this.usersService.update(foundUser.id, { verified: true }),
);
}
Example #12
Source File: mailer-auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiBearerAuth()
@Delete('logout-all')
@UseGuards(RolesGuard)
@Roles(RolesEnum.admin)
@HttpCode(HttpStatus.NO_CONTENT)
async logoutAll(): Promise<{}> {
return this.authService.deleteAllTokens();
}
Example #13
Source File: mailer-auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'No content. 204',
})
@ApiNotFoundResponse({
schema: {
type: 'object',
example: {
message: 'string',
error: 'Not Found',
},
},
description: 'User was not found',
})
@HttpCode(HttpStatus.NO_CONTENT)
@Get('verify/:token')
async verifyUser(@Param('token') token: string): Promise<SuccessResponseInterface | never> {
const { id } = await this.authService.verifyEmailVerToken(
token,
this.configService.get<string>('ACCESS_TOKEN') || '<%= config.accessTokenSecret %>',
);
const foundUser = await this.usersService.getUnverifiedUserById(id);
if (!foundUser) {
throw new NotFoundException('The user does not exist');
}
return ResponseUtils.success(
'users',
await this.usersService.update(foundUser.id, { verified: true }),
);
}
Example #14
Source File: user.controller.ts From nestjs-api-example with MIT License | 6 votes |
@Delete(':id')
@ApiOperation({ summary: '유저 삭제 API' })
@ApiNoContentResponse({ description: 'Id가 일치하는 유저 정보를 삭제한다.' })
async delete(
@Param('id', new ParseIntPipe()) id: number,
@Res() res: Response,
) {
await this.userService.deleteUser(id);
return res.status(HttpStatus.NO_CONTENT).send();
}
Example #15
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'No content. 204',
})
@ApiNotFoundResponse({
schema: {
type: 'object',
example: {
message: 'string',
error: 'Not Found',
},
},
description: 'User was not found',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@HttpCode(HttpStatus.NO_CONTENT)
@Put('verify')
async verifyUser(@Body() verifyUserDto: VerifyUserDto): Promise<SuccessResponseInterface | never> {
const foundUser = await this.usersService.getUnverifiedUserByEmail(
verifyUserDto.email
);
if (!foundUser) {
throw new NotFoundException('The user does not exist');
}
return ResponseUtils.success(
'users',
await this.usersService.update(foundUser.id, { verified: true }),
);
}
Example #16
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({ description: 'No content. 204' })
@UseGuards(IsLoggedGuard)
@Delete('logout')
@HttpCode(204)
async logout(@Req() req: ExpressRequest): Promise<{}> {
await req.logout();
return {};
}
Example #17
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'No content. 204',
})
@ApiNotFoundResponse({
schema: {
type: 'object',
example: {
message: 'string',
error: 'Not Found',
},
},
description: 'User was not found',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiBearerAuth()
@HttpCode(HttpStatus.NO_CONTENT)
@Auth(RolesEnum.admin)
@Put('verify')
async verifyUser(@Body() verifyUserDto: VerifyUserDto): Promise<User | null> {
const foundUser = await this.usersService.getUnverifiedUserByEmail(
verifyUserDto.email,
) as UserDocument;
if (!foundUser) {
throw new NotFoundException('The user does not exist');
}
return this.usersService.update(foundUser._id, { verified: true });
}
Example #18
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiBearerAuth()
@Delete('logout-all')
@Auth(RolesEnum.admin)
@HttpCode(HttpStatus.NO_CONTENT)
async logoutAll(): Promise<{}> {
return this.authService.deleteAllTokens();
}
Example #19
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({ description: 'No content. 204' })
@UseGuards(IsLoggedGuard)
@Delete('logout')
@HttpCode(204)
async logout(@Req() req: ExpressRequest): Promise<{}> {
await req.logout();
return {};
}
Example #20
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'No content. 204',
})
@ApiNotFoundResponse({
schema: {
type: 'object',
example: {
message: 'string',
error: 'Not Found',
},
},
description: 'User was not found',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@HttpCode(HttpStatus.NO_CONTENT)
@Put('verify')
async verifyUser(@Body() verifyUserDto: VerifyUserDto): Promise<{} | never> {
const foundUser = await this.usersService.getUnverifiedUserByEmail(
verifyUserDto.email,
);
if (!foundUser) {
throw new NotFoundException('The user does not exist');
}
return this.usersService.update(foundUser.id, { verified: true });
}
Example #21
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiInternalServerErrorResponse({ description: '500. InternalServerError' })
@ApiBearerAuth()
@Delete('logout-all')
@UseGuards(RolesGuard)
@Roles(RolesEnum.admin)
@HttpCode(HttpStatus.NO_CONTENT)
async logoutAll(): Promise<{}> {
return this.authService.deleteAllTokens();
}
Example #22
Source File: mailer-auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiBearerAuth()
@Delete('logout-all')
@Auth(RolesEnum.admin)
@HttpCode(HttpStatus.NO_CONTENT)
async logoutAll(): Promise<{}> {
return this.authService.deleteAllTokens();
}
Example #23
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiBearerAuth()
@Delete('logout-all')
@Auth(RolesEnum.admin)
@HttpCode(HttpStatus.NO_CONTENT)
async logoutAll(): Promise<{}> {
return this.authService.deleteAllTokens();
}
Example #24
Source File: mailer-auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiNoContentResponse({
description: 'No content. 204',
})
@ApiNotFoundResponse({
schema: {
type: 'object',
example: {
message: 'string',
error: 'Not Found',
},
},
description: 'User was not found',
})
@HttpCode(HttpStatus.NO_CONTENT)
@Get('verify/:token')
async verifyUser(@Param('token') token: string): Promise<SuccessResponseInterface | never> {
const { id } = await this.authService.verifyEmailVerToken(
token,
this.configService.get<string>('ACCESS_TOKEN') || '<%= config.accessTokenSecret %>',
);
const foundUser = await this.usersService.getUnverifiedUserById(id) as UserDocument;
if (!foundUser) {
throw new NotFoundException('The user does not exist');
}
return ResponseUtils.success(
'users',
await this.usersService.update(foundUser._id, { verified: true }),
);
}
Example #25
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 5 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiUnauthorizedResponse({
schema: {
type: 'object',
example: {
message: 'string',
},
},
description: 'Token has been expired',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiBearerAuth()
@UseGuards(JwtAccessGuard)
@Delete('logout/:token')
@HttpCode(HttpStatus.NO_CONTENT)
async logout(@Param('token') token: string): Promise<{} | never> {
const decodedUser: DecodedUser | null = await this.authService.verifyToken(
token,
this.configService.get<string>('ACCESS_TOKEN') || '<%= config.accessTokenSecret %>',
);
if (!decodedUser) {
throw new ForbiddenException('Incorrect token');
}
const deletedUsersCount = await this.authService.deleteTokenByEmail(
decodedUser.email,
);
if (deletedUsersCount === 0) {
throw new NotFoundException();
}
return {};
}
Example #26
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 5 votes |
@ApiNoContentResponse({
description: 'No content. 204',
})
@ApiNotFoundResponse({
schema: {
type: 'object',
example: {
message: 'string',
error: 'Not Found',
},
},
description: 'User was not found',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiBearerAuth()
@HttpCode(HttpStatus.NO_CONTENT)
@Auth(RolesEnum.admin)
@Put('verify')
async verifyUser(@Body() verifyUserDto: VerifyUserDto): Promise<SuccessResponseInterface | never> {
const foundUser = await this.usersService.getUnverifiedUserByEmail(
verifyUserDto.email
) as UserDocument;
if (!foundUser) {
throw new NotFoundException('The user does not exist');
}
return ResponseUtils.success(
'users',
await this.usersService.update(foundUser._id, { verified: true }),
);
}
Example #27
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 5 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiUnauthorizedResponse({
schema: {
type: 'object',
example: {
message: 'string',
},
},
description: 'Token has been expired',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiBearerAuth()
@Auth()
@Delete('logout')
@HttpCode(HttpStatus.NO_CONTENT)
async logout(@AuthBearer() token: string): Promise<{} | never> {
const decodedUser: DecodedUser | null = await this.authService.verifyToken(
token,
this.configService.get<string>('ACCESS_TOKEN') || '<%= config.accessTokenSecret %>',
);
if (!decodedUser) {
throw new ForbiddenException('Incorrect token');
}
const deletedUsersCount = await this.authService.deleteTokenByEmail(
decodedUser.email,
);
if (deletedUsersCount === 0) {
throw new NotFoundException();
}
return {};
}
Example #28
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 5 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiUnauthorizedResponse({
schema: {
type: 'object',
example: {
message: 'string',
},
},
description: 'Token has been expired',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: 'InternalServerError',
})
@ApiBearerAuth()
@Auth()
@Delete('logout/:token')
@HttpCode(HttpStatus.NO_CONTENT)
async logout(@Param('token') token: string): Promise<{} | never> {
const decodedUser: DecodedUser | null = await this.authService.verifyToken(
token,
this.configService.get<string>('ACCESS_TOKEN') || '<%= config.accessTokenSecret %>',
);
if (!decodedUser) {
throw new ForbiddenException('Incorrect token');
}
const deletedUsersCount = await this.authService.deleteTokenByEmail(
decodedUser.email,
);
if (deletedUsersCount === 0) {
throw new NotFoundException();
}
return {};
}
Example #29
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 5 votes |
@ApiNoContentResponse({
description: 'no content',
})
@ApiUnauthorizedResponse({
schema: {
type: 'object',
example: {
message: 'string',
},
},
description: 'Token has been expired',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: '500. InternalServerError',
})
@ApiBearerAuth()
@UseGuards(JwtAccessGuard)
@Delete('logout/:token')
@HttpCode(HttpStatus.NO_CONTENT)
async logout(@Param('token') token: string): Promise<{} | never> {
const decodedUser: DecodedUser | null = await this.authService.verifyToken(
token,
this.configService.get<string>('ACCESS_TOKEN') || '<%= config.accessTokenSecret %>',
);
if (!decodedUser) {
throw new ForbiddenException('Incorrect token');
}
const deletedUsersCount = await this.authService.deleteTokenByEmail(
decodedUser.email,
);
if (deletedUsersCount === 0) {
throw new NotFoundException();
}
return {};
}