mirror of
https://github.com/n08i40k/schedule-parser-next.git
synced 2025-12-06 17:57:45 +03:00
Много
This commit is contained in:
30
src/users/users.controller.ts
Normal file
30
src/users/users.controller.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
HttpCode,
|
||||
HttpStatus,
|
||||
NotFoundException,
|
||||
UseGuards,
|
||||
} from "@nestjs/common";
|
||||
import { AuthGuard } from "../auth/auth.guard";
|
||||
import { ClientUserDto } from "../dto/user.dto";
|
||||
import { ResultDto } from "../utility/validation/class-validator.interceptor";
|
||||
import { UserToken } from "../auth/auth.decorator";
|
||||
import { AuthService } from "../auth/auth.service";
|
||||
|
||||
@Controller("api/v1/users")
|
||||
@UseGuards(AuthGuard)
|
||||
export class UsersController {
|
||||
constructor(private readonly authService: AuthService) {}
|
||||
|
||||
@ResultDto(ClientUserDto)
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Get("me")
|
||||
async getMe(@UserToken() token: string): Promise<ClientUserDto> {
|
||||
const userDto = await this.authService.decodeUserToken(token);
|
||||
if (!userDto)
|
||||
throw new NotFoundException("Не удалось найти пользователя!");
|
||||
|
||||
return ClientUserDto.fromUserDto(userDto);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user