@nestjs/swagger#ApiCookieAuth TypeScript Examples
The following examples show how to use
@nestjs/swagger#ApiCookieAuth.
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 |
@ApiCookieAuth()
@ApiBody({ type: SignInDto })
@ApiMovedPermanentlyResponse({ description: 'Returns 301 if login is ok' })
@ApiInternalServerErrorResponse({
description: 'Returns 500 if smth has been failed',
})
@HttpCode(HttpStatus.MOVED_PERMANENTLY)
@UseGuards(LocalAuthGuard)
@Post('/login')
@Redirect('/v1/home')
public login(): void {}
Example #2
Source File: home.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiCookieAuth()
@ApiOkResponse({
schema: {
type: 'object',
properties: {
data: {
$ref: getSchemaPath(User),
},
},
},
description: 'Returns the logged user',
})
@ApiUnauthorizedResponse({
schema: {
type: 'object',
example: {
message: 'string',
},
},
description: 'Returns the unauthorized error',
})
@UseGuards(IsLoggedGuard)
@Get('/')
@Render('home')
public getIndex(@RequestUser() user: User): User {
return user;
}
Example #3
Source File: users.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiCookieAuth()
@ApiOkResponse({
schema: {
type: 'object',
properties: {
data: {
$ref: getSchemaPath(User),
},
},
},
description: 'Returns 200 if the template has been rendered successfully',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: 'Internal Server Error',
})
@UseGuards(IsLoggedGuard)
@Get('/profile')
@Render('profile')
public getProfile(@RequestUser() user: User): User {
return user;
}
Example #4
Source File: users.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiCookieAuth()
@ApiOkResponse({
schema: {
type: 'object',
properties: {
data: {
$ref: getSchemaPath(User),
},
},
},
description: 'Returns 200 if the template has been rendered successfully',
})
@UseGuards(RolesGuard)
@Roles(RolesEnum.admin)
@Get()
@Render('all-users')
public async getAllUsers(@RequestUser() admin: User): Promise<any> {
const foundUsers = await this.usersService.getAll();
return { admin, users: foundUsers };
}
Example #5
Source File: home.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiCookieAuth()
@ApiOkResponse({
schema: {
type: 'object',
properties: {
data: {
$ref: getSchemaPath(UserEntity),
},
},
},
description: 'Returns the logged user',
})
@ApiUnauthorizedResponse({
schema: {
type: 'object',
example: {
message: 'string',
},
},
description: 'Returns the unauthorized error',
})
@UseGuards(IsLoggedGuard)
@Get('/')
@Render('home')
public getIndex(@RequestUser() user: UserEntity): UserEntity {
return user;
}
Example #6
Source File: users.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiCookieAuth()
@ApiOkResponse({
schema: {
type: 'object',
properties: {
data: {
$ref: getSchemaPath(UserEntity),
},
},
},
description: 'Returns 200 if the template has been rendered successfully',
})
@ApiInternalServerErrorResponse({
schema: {
type: 'object',
example: {
message: 'string',
details: {},
},
},
description: 'Internal Server Error',
})
@UseGuards(IsLoggedGuard)
@Get('/profile')
@Render('profile')
public getProfile(@RequestUser() user: UserEntity): UserEntity {
return user;
}
Example #7
Source File: users.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiCookieAuth()
@ApiOkResponse({
schema: {
type: 'object',
properties: {
data: {
$ref: getSchemaPath(UserEntity),
},
},
},
description: 'Returns 200 if the template has been rendered successfully',
})
@UseGuards(RolesGuard)
@Roles(RolesEnum.admin)
@Get()
@Render('all-users')
public async getAllVerified(@RequestUser() admin: UserEntity): Promise<any> {
const foundUsers = await this.usersService.getAll();
return { admin, users: foundUsers };
}
Example #8
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiCookieAuth()
@ApiBody({ type: SignInDto })
@ApiMovedPermanentlyResponse({ description: 'Returns 301 if login is ok' })
@ApiInternalServerErrorResponse({
description: 'Returns 500 if smth has been failed',
})
@HttpCode(HttpStatus.MOVED_PERMANENTLY)
@UseGuards(LocalAuthGuard)
@Post('/login')
@Redirect('/v1/home')
public login(): void { }
Example #9
Source File: auth.controller.ts From nest-js-boilerplate with MIT License | 6 votes |
@ApiCookieAuth()
@ApiBody({ type: SignInDto })
@ApiMovedPermanentlyResponse({ description: 'Returns 301 if login is ok' })
@ApiInternalServerErrorResponse({
description: 'Returns 500 if smth has been failed',
})
@HttpCode(HttpStatus.MOVED_PERMANENTLY)
@UseGuards(LocalAuthGuard)
@Post('/login')
@Redirect('/home')
public login(): void {}