nest-project/src/auth/auth.controller.ts

22 lines
645 B
TypeScript
Raw Normal View History

2023-02-17 14:21:08 +08:00
import { Body, Controller, Post } from '@nestjs/common'
2023-02-16 01:18:55 +08:00
import { AuthService } from './auth.service'
import { CreateUserDto } from 'src/users/dto/create-user.dto'
2023-02-16 17:10:03 +08:00
import { ApiTags } from '@nestjs/swagger'
2023-02-16 01:18:55 +08:00
import { LoginInputDto } from './dto/login-input.dto'
2023-02-17 14:21:08 +08:00
@ApiTags('Auth')
@Controller('api/auth')
2023-02-16 01:18:55 +08:00
export class AuthController {
2023-02-17 15:04:35 +08:00
constructor(private readonly authService: AuthService) {}
2023-02-16 01:18:55 +08:00
2023-02-17 14:21:08 +08:00
@Post('register')
2023-02-16 01:18:55 +08:00
async register(@Body() userData: CreateUserDto) {
2023-02-16 10:40:03 +08:00
return this.authService.register(userData)
2023-02-16 01:18:55 +08:00
}
2023-02-17 14:21:08 +08:00
@Post('login')
2023-02-16 01:18:55 +08:00
async login(@Body() user: LoginInputDto) {
return this.authService.login(user.email, user.password)
}
}