22 lines
606 B
TypeScript
22 lines
606 B
TypeScript
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
|
|
import { AuthService } from './auth.service';
|
|
import { LoginDto } from './dto/login.dto';
|
|
import { JwtAuthGuard } from './jwt-auth.guard';
|
|
import { CurrentUser } from './current-user.decorator';
|
|
|
|
@Controller('auth')
|
|
export class AuthController {
|
|
constructor(private readonly authService: AuthService) {}
|
|
|
|
@Post('login')
|
|
login(@Body() dto: LoginDto) {
|
|
return this.authService.login(dto);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get('me')
|
|
me(@CurrentUser() user: { id: string }) {
|
|
return this.authService.me(user.id);
|
|
}
|
|
}
|