| 1 | import { Body, Controller, Get, Post } from '@nestjs/common'; |
| 2 | import { AuthService } |
| 3 | import { LoginDTO } |
| 4 | import { RegisterDTO } |
| 5 | import { ApiBearerAuth, ApiConflictResponse |
| 6 | import { LoginEntity } |
| 7 | import { RegisterEntity } |
| 8 | import { UserEntity } |
| 9 | import { GenericErrorEntity } |
| 10 | import { Auth } |
| 11 | import { User } |
| 12 | |
| 13 | @Controller('auth') |
| 14 | @ApiTags("Authentication") |
| 15 | @ApiBearerAuth() |
| 16 | export class AuthController |
| 17 | constructor(private readonly |
| 18 | |
| 19 | @Post('login' |
| 20 | @ApiOperation({ |
| 21 | summary: 'Login', |
| 22 | description: 'Login' |
| 23 | }) |
| 24 | @ApiCreatedResponse({ |
| 25 | type:LoginEntity |
| 26 | }) |
| 27 | @ApiNotFoundResponse({type: |
| 28 | @ApiUnauthorizedResponse({type: |
| 29 | async login(@ |
| 30 | return await this |
| 31 | } |
| 32 | |
| 33 | @ApiCreatedResponse({ |
| 34 | type:RegisterEntity |
| 35 | }) |
| 36 | @ApiOperation({ |
| 37 | summary: 'Register', |
| 38 | description: 'Create a new user' |
| 39 | }) |
| 40 | @ApiConflictResponse({type: |
| 41 | @Post('register' |
| 42 | async register(@ |
| 43 | return await this |
| 44 | } |
| 45 | |
| 46 | @ApiOperation({ |
| 47 | summary: 'Get current user', |
| 48 | description: 'Get current user', |
| 49 | }) |
| 50 | @ApiBearerAuth('JWT-auth' |
| 51 | @Get('@me' |
| 52 | @ApiNotFoundResponse({ type |
| 53 | @ApiOkResponse({ |
| 54 | type: UserEntity, |
| 55 | }) |
| 56 | async getCurrentUser(@ |
| 57 | return this.authService |
| 58 | } |
| 59 | } |