All files / src/auth auth.controller.ts

100% Statements 13/13
100% Branches 0/0
100% Functions 3/3
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 296x 6x 6x 6x 6x     6x 6x       6x     6x                 6x 2x      
import { Controller, Post, Body, HttpCode, HttpStatus } from '@nestjs/common';
import { AuthService } from './auth.service';
import { RegisterUserDto } from './dto/register-user.dto';
import { LoginUserDto } from './dto/login-user.dto';
import { ApiResponse } from '@nestjs/swagger';
 
@Controller('auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}
 
  @Post('register')
  @HttpCode(HttpStatus.CREATED)
  async register(
    @Body() registerUserDto: RegisterUserDto,
  ): Promise<{ message: string }> {
    return await this.authService.register(registerUserDto);
  }
  @Post('login')
  @ApiResponse({
    status: 200,
    description: 'login successful',
  })
  @ApiResponse({ status: 404, description: 'Not found' })
  @HttpCode(HttpStatus.OK)
  login(@Body() loginDto: LoginUserDto) {
    return this.authService.loginUser(loginDto.email, loginDto.password);
  }
}