Skip to content

Instantly share code, notes, and snippets.

@jacobdo2
Created June 8, 2020 09:13
Show Gist options
  • Save jacobdo2/024d9bc0c91510682023c4a69397739f to your computer and use it in GitHub Desktop.
Save jacobdo2/024d9bc0c91510682023c4a69397739f to your computer and use it in GitHub Desktop.
AuthController
import { BadRequestException, Body, Controller, Post } from '@nestjs/common';
import { AuthService } from './auth.service';
@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}
@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