✨ feat(src/modules/likes/likes.controller.ts): обновляет ответы API для создания лайка и получения совпадений ✨ feat(src/auth/auth.controller.ts): обновляет ответы API для регистрации, входа и выхода пользователя ✨ feat(src/modules/media/media.controller.ts): обновляет ответы API для загрузки и получения медиа ✨ feat(src/modules/users/users.controller.ts): обновляет ответы API для получения и управления пользователями ✨ feat(src/modules/dates/dto/dates-response.dto.ts): изменяет название свойства статуса даты на dateStatus ✨ feat(src/modules/cities/cities.controller.ts): обновляет ответы API для получения и создания городов и районов ✨ feat(src/modules/chat/chat.controller.ts): обновляет ответы API для создания и получения чатов и сообщений ✨ feat(src/modules/reports/reports.controller.ts): обновляет ответы API для создания и получения отчетов ✨ feat(src/modules/feed/feed.controller.ts): обновляет структуру ответа
64 lines
2.2 KiB
TypeScript
64 lines
2.2 KiB
TypeScript
import { Body, Controller, Post, UseGuards } from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiBody, ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { AuthService } from './auth.service';
|
|
import { LoginDto } from './dto/login.dto';
|
|
import { RefreshTokenDto } from './dto/refresh-token.dto';
|
|
import { RegisterDto } from './dto/register.dto';
|
|
import { TokensResponseDto } from './dto/tokens-response.dto';
|
|
import { Public } from '../common/decorators/public.decorator';
|
|
import { CurrentUser } from '../common/decorators/current-user.decorator';
|
|
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
|
|
import { MessageResponseDto } from '../common/dto/message-response.dto';
|
|
|
|
@ApiTags('auth')
|
|
@Controller('auth')
|
|
export class AuthController {
|
|
constructor(private readonly authService: AuthService) {}
|
|
|
|
@Public()
|
|
@Post('register')
|
|
@ApiOperation({ summary: 'Register new user' })
|
|
@ApiCreatedResponse({ type: TokensResponseDto })
|
|
register(@Body() dto: RegisterDto) {
|
|
return this.authService.register(dto);
|
|
}
|
|
|
|
@Public()
|
|
@Post('login')
|
|
@ApiOperation({ summary: 'Login with phone and password' })
|
|
@ApiCreatedResponse({ type: TokensResponseDto })
|
|
login(@Body() dto: LoginDto) {
|
|
return this.authService.login(dto);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Post('logout')
|
|
@ApiBearerAuth()
|
|
@ApiOperation({ summary: 'Logout current user' })
|
|
@ApiOkResponse({ type: MessageResponseDto })
|
|
logout(@CurrentUser('id') userId: string) {
|
|
return this.authService.logout(userId);
|
|
}
|
|
|
|
@Public()
|
|
@Post('refresh')
|
|
@ApiOperation({ summary: 'Refresh access token' })
|
|
@ApiCreatedResponse({ type: TokensResponseDto })
|
|
refresh(@Body() dto: RefreshTokenDto) {
|
|
return this.authService.refreshTokens(dto.refreshToken);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Post('fcm-token')
|
|
@ApiBearerAuth()
|
|
@ApiOperation({ summary: 'Update FCM push token' })
|
|
@ApiBody({ schema: { type: 'object', properties: { fcmToken: { type: 'string', example: 'firebase-token-abc123' } }, required: ['fcmToken'] } })
|
|
@ApiOkResponse({ type: MessageResponseDto })
|
|
updateFcmToken(
|
|
@CurrentUser('id') userId: string,
|
|
@Body('fcmToken') fcmToken: string,
|
|
) {
|
|
return this.authService.updateFcmToken(userId, fcmToken);
|
|
}
|
|
}
|