Loading backend/src/auth/user/authUsercontroller.ts 0 → 100644 +50 −0 Original line number Diff line number Diff line import { Body, Controller, Post } from '@nestjs/common'; import { ApiBearerAuth, ApiBody, ApiCreatedResponse, ApiTags, ApiUnauthorizedResponse, } from '@nestjs/swagger'; import { AuthUserService } from './authUserservice'; import { CreateUserDto } from 'src/user/dto/create-user.dto'; import { LoginUserDto } from './dto/login-user.dto'; @Controller('') @ApiTags('Create user account and sign in as user') export class AuthUserController { constructor(private readonly authUserService: AuthUserService) {} @ApiBody({ type: CreateUserDto }) @ApiBearerAuth() @ApiCreatedResponse({ content: { 'application/json': { example: { token: 'token', }, }, }, }) @Post('user/signup') async signUp(@Body() createAdminDto: CreateUserDto) { try { const accessToken = await this.authUserService.signUp(createAdminDto); return { token: accessToken }; } catch (e) { throw e; } } @ApiBody({ type: LoginUserDto }) @ApiUnauthorizedResponse() @Post('user/signin') async signIn(@Body() loginAdminDto: LoginUserDto) { try { const adminSigninResDto = await this.authUserService.signIn(loginAdminDto); return adminSigninResDto; } catch (e) { throw e; } } } Loading
backend/src/auth/user/authUsercontroller.ts 0 → 100644 +50 −0 Original line number Diff line number Diff line import { Body, Controller, Post } from '@nestjs/common'; import { ApiBearerAuth, ApiBody, ApiCreatedResponse, ApiTags, ApiUnauthorizedResponse, } from '@nestjs/swagger'; import { AuthUserService } from './authUserservice'; import { CreateUserDto } from 'src/user/dto/create-user.dto'; import { LoginUserDto } from './dto/login-user.dto'; @Controller('') @ApiTags('Create user account and sign in as user') export class AuthUserController { constructor(private readonly authUserService: AuthUserService) {} @ApiBody({ type: CreateUserDto }) @ApiBearerAuth() @ApiCreatedResponse({ content: { 'application/json': { example: { token: 'token', }, }, }, }) @Post('user/signup') async signUp(@Body() createAdminDto: CreateUserDto) { try { const accessToken = await this.authUserService.signUp(createAdminDto); return { token: accessToken }; } catch (e) { throw e; } } @ApiBody({ type: LoginUserDto }) @ApiUnauthorizedResponse() @Post('user/signin') async signIn(@Body() loginAdminDto: LoginUserDto) { try { const adminSigninResDto = await this.authUserService.signIn(loginAdminDto); return adminSigninResDto; } catch (e) { throw e; } } }