Skip to content

Instantly share code, notes, and snippets.

@akkonrad
Created October 24, 2022 12:38
Show Gist options
  • Save akkonrad/c40acb4ed27979c07b99e536fa71008c to your computer and use it in GitHub Desktop.
Save akkonrad/c40acb4ed27979c07b99e536fa71008c to your computer and use it in GitHub Desktop.
auth/auth.controller.ts
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