/
Masunium
/
forms-test-backend
Обзор
Документация
Войти
/
Masunium
/
forms-test-backend
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
response
src/auth/auth.controller.ts
63 строки
1 KB
Masunium
forms CRUD and auth improvement
02 мар 2026, 19:14
02 мар 2026, 19:14
6758017
Код
Авторство
О чём код?
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Req, Res, UseGuards, } from '@nestjs/common'; import { AuthService } from './auth.service'; import { RegisterRequestDto } from './dto/register.dto'; import { LoginRequestDto } from './dto/login.dto'; import type { Request, Response } from 'express'; import { Authorization } from './decorators/authorization.decorator'; import { Authorized } from './decorators/authorized.decorator'; import type { User } from '@prisma/client'; @Controller('auth') export class AuthController { constructor(private readonly authService: AuthService) {} @Post('register') @HttpCode(HttpStatus.CREATED) async register( @Res({ passthrough: true }) res: Response, @Body() dto: RegisterRequestDto, ) { return await this.authService.register(res, dto); } @Post('login') @HttpCode(HttpStatus.OK) async login( @Res({ passthrough: true }) res: Response, @Body() dto: LoginRequestDto, ) { return await this.authService.login(res, dto); } @Post('refresh') @HttpCode(HttpStatus.OK) async refresh( @Req() req: Request, @Res({ passthrough: true }) res: Response, ) { return await this.authService.refresh(req, res); } @Post('logout') @HttpCode(HttpStatus.OK) async logout(@Res({ passthrough: true }) res: Response) { return await this.authService.logout(res); } @Authorization() @Get('@me') @HttpCode(HttpStatus.OK) async me(@Authorized() user: User) { return user; } }