Created
June 17, 2020 12:15
-
-
Save jacobdo2/4b33e33ae9576386dd68f3f4fc3784c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BadRequestException, Body, Controller, Post } from '@nestjs/common'; | |
import { AuthService } from './auth.service'; | |
@Controller('auth') | |
export class AuthController { | |
constructor(private readonly authService: AuthService) {} | |
@Post('register') | |
async register( | |
@Body() registerRequest: { name: string; password: string; email: string }, | |
) { | |
return await this.authService.registerUser(registerRequest) | |
} | |
@Post('login') | |
async login(@Body() authenticateRequest: { name: string; password: string }) { | |
try { | |
return await this.authService.authenticateUser(authenticateRequest); | |
} catch (e) { | |
throw new BadRequestException(e.message); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment