feat(src/modules/greetings/greetings.controller.ts): обновляет ответы API для получения и создания фраз приветствия

 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): обновляет структуру ответа
This commit is contained in:
Oscar
2026-06-08 16:41:08 +03:00
parent 8b852c9f28
commit 1662bb7dc8
14 changed files with 66 additions and 56 deletions

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
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';
@@ -18,7 +18,7 @@ export class AuthController {
@Public()
@Post('register')
@ApiOperation({ summary: 'Register new user' })
@ApiResponse({ status: 201, type: TokensResponseDto })
@ApiCreatedResponse({ type: TokensResponseDto })
register(@Body() dto: RegisterDto) {
return this.authService.register(dto);
}
@@ -26,7 +26,7 @@ export class AuthController {
@Public()
@Post('login')
@ApiOperation({ summary: 'Login with phone and password' })
@ApiResponse({ status: 201, type: TokensResponseDto })
@ApiCreatedResponse({ type: TokensResponseDto })
login(@Body() dto: LoginDto) {
return this.authService.login(dto);
}
@@ -35,7 +35,7 @@ export class AuthController {
@Post('logout')
@ApiBearerAuth()
@ApiOperation({ summary: 'Logout current user' })
@ApiResponse({ status: 201, type: MessageResponseDto })
@ApiOkResponse({ type: MessageResponseDto })
logout(@CurrentUser('id') userId: string) {
return this.authService.logout(userId);
}
@@ -43,7 +43,7 @@ export class AuthController {
@Public()
@Post('refresh')
@ApiOperation({ summary: 'Refresh access token' })
@ApiResponse({ status: 201, type: TokensResponseDto })
@ApiCreatedResponse({ type: TokensResponseDto })
refresh(@Body() dto: RefreshTokenDto) {
return this.authService.refreshTokens(dto.refreshToken);
}
@@ -53,7 +53,7 @@ export class AuthController {
@ApiBearerAuth()
@ApiOperation({ summary: 'Update FCM push token' })
@ApiBody({ schema: { type: 'object', properties: { fcmToken: { type: 'string', example: 'firebase-token-abc123' } }, required: ['fcmToken'] } })
@ApiResponse({ status: 201, type: MessageResponseDto })
@ApiOkResponse({ type: MessageResponseDto })
updateFcmToken(
@CurrentUser('id') userId: string,
@Body('fcmToken') fcmToken: string,

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Delete, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { ChatService } from './chat.service';
@@ -17,14 +17,14 @@ export class ChatController {
@Post()
@ApiOperation({ summary: 'Open a chat for a match' })
@ApiResponse({ status: 201, type: ChatDto })
@ApiCreatedResponse({ type: ChatDto })
createChat(@CurrentUser('id') userId: string, @Body() dto: CreateChatDto) {
return this.chatService.createChat(userId, dto);
}
@Get()
@ApiOperation({ summary: 'Get active chats for a profile' })
@ApiResponse({ status: 200, type: [ChatDto] })
@ApiOkResponse({ type: [ChatDto] })
getChats(
@CurrentUser('id') userId: string,
@Query('profileId') profileId: string,
@@ -36,7 +36,7 @@ export class ChatController {
@ApiOperation({ summary: 'Get chat messages' })
@ApiQuery({ name: 'page', required: false, schema: { default: 1, type: 'number' } })
@ApiQuery({ name: 'limit', required: false, schema: { default: 50, type: 'number' } })
@ApiResponse({ status: 200, type: [MessageDto] })
@ApiOkResponse({ type: [MessageDto] })
getMessages(
@CurrentUser('id') userId: string,
@Query('profileId') profileId: string,
@@ -49,7 +49,7 @@ export class ChatController {
@Post(':chatId/messages')
@ApiOperation({ summary: 'Send a message' })
@ApiResponse({ status: 201, type: MessageDto })
@ApiCreatedResponse({ type: MessageDto })
sendMessage(
@CurrentUser('id') userId: string,
@Query('profileId') profileId: string,
@@ -61,7 +61,7 @@ export class ChatController {
@Delete(':chatId')
@ApiOperation({ summary: 'Close a chat' })
@ApiResponse({ status: 200, type: MessageResponseDto })
@ApiOkResponse({ type: MessageResponseDto })
closeChat(
@CurrentUser('id') userId: string,
@Query('profileId') profileId: string,

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { Public } from '../../common/decorators/public.decorator';
import { Roles } from '../../common/decorators/roles.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
@@ -16,7 +16,7 @@ export class CitiesController {
@Public()
@Get()
@ApiOperation({ summary: 'Get all cities' })
@ApiResponse({ status: 200, type: [CityResponseDto] })
@ApiOkResponse({ type: [CityResponseDto] })
findAll() {
return this.citiesService.findAll();
}
@@ -24,7 +24,7 @@ export class CitiesController {
@Public()
@Get(':cityId/districts')
@ApiOperation({ summary: 'Get districts for a city' })
@ApiResponse({ status: 200, type: [DistrictResponseDto] })
@ApiOkResponse({ type: [DistrictResponseDto] })
findDistricts(@Param('cityId') cityId: string) {
return this.citiesService.findDistricts(cityId);
}
@@ -34,7 +34,7 @@ export class CitiesController {
@Roles('admin')
@Post()
@ApiOperation({ summary: 'Create city (admin only)' })
@ApiResponse({ status: 201, type: CityResponseDto })
@ApiCreatedResponse({ type: CityResponseDto })
createCity(@Body() body: CreateCityDto) {
return this.citiesService.createCity(body.name, body.lat, body.lng);
}
@@ -44,7 +44,7 @@ export class CitiesController {
@Roles('admin')
@Post(':cityId/districts')
@ApiOperation({ summary: 'Create district (admin only)' })
@ApiResponse({ status: 201, type: DistrictResponseDto })
@ApiCreatedResponse({ type: DistrictResponseDto })
createDistrict(@Param('cityId') cityId: string, @Body() body: CreateDistrictDto) {
return this.citiesService.createDistrict(cityId, body.name);
}

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Get, Param, Patch, Post, Query, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { DatesService } from './dates.service';
@@ -16,14 +16,14 @@ export class DatesController {
@Post()
@ApiOperation({ summary: 'Propose a meetup' })
@ApiResponse({ status: 201, type: DateDto })
@ApiCreatedResponse({ type: DateDto })
create(@CurrentUser('id') userId: string, @Body() dto: CreateDateDto) {
return this.datesService.create(userId, dto);
}
@Get()
@ApiOperation({ summary: 'Get dates for a profile' })
@ApiResponse({ status: 200, type: [DateWithStatusDto] })
@ApiOkResponse({ type: [DateWithStatusDto] })
getDates(
@CurrentUser('id') userId: string,
@Query('profileId') profileId: string,
@@ -33,7 +33,7 @@ export class DatesController {
@Patch(':id/status')
@ApiOperation({ summary: 'Update date status' })
@ApiResponse({ status: 200, type: DateDto })
@ApiOkResponse({ type: DateDto })
updateStatus(
@CurrentUser('id') userId: string,
@Query('profileId') profileId: string,
@@ -45,7 +45,7 @@ export class DatesController {
@Get('statuses')
@ApiOperation({ summary: 'Get available date statuses' })
@ApiResponse({ status: 200, type: [DateStatusDto] })
@ApiOkResponse({ type: [DateStatusDto] })
getStatuses() {
return this.datesService.getStatuses();
}

View File

@@ -17,5 +17,5 @@ export class DateDto {
export class DateWithStatusDto {
@ApiProperty({ type: DateDto }) date: DateDto;
@ApiPropertyOptional({ type: DateStatusDto, nullable: true }) date_status: DateStatusDto | null;
@ApiPropertyOptional({ type: DateStatusDto, nullable: true }) dateStatus: DateStatusDto | null;
}

View File

@@ -1,5 +1,5 @@
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiExtraModels, ApiOkResponse, ApiOperation, ApiTags, getSchemaPath } from '@nestjs/swagger';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { FeedFilterDto } from './dto/feed-filter.dto';
@@ -9,13 +9,23 @@ import { ProfileResponseDto } from '../profiles/dto/profile-response.dto';
@ApiTags('feed')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@ApiExtraModels(ProfileResponseDto)
@Controller('feed')
export class FeedController {
constructor(private readonly feedService: FeedService) {}
@Get()
@ApiOperation({ summary: 'Get filtered feed (requires profileId)' })
@ApiResponse({ status: 200, type: [ProfileResponseDto] })
@ApiOkResponse({
schema: {
properties: {
items: { type: 'array', items: { $ref: getSchemaPath(ProfileResponseDto) } },
page: { type: 'number', example: 1 },
limit: { type: 'number', example: 20 },
},
required: ['items', 'page', 'limit'],
},
})
getFeed(@CurrentUser('id') userId: string, @Query() filter: FeedFilterDto) {
return this.feedService.getFeed(userId, filter);
}

View File

@@ -61,7 +61,7 @@ export class FeedService {
.where(inArray(profileTag.tagId, tagIds));
const matchedIds = tagMatches.map((r) => r.profileId);
if (matchedIds.length === 0) return { data: [], page, limit };
if (matchedIds.length === 0) return { items: [], page, limit };
conditions.push(inArray(profile.id, matchedIds));
}
@@ -104,7 +104,7 @@ export class FeedService {
}),
);
return { data: enriched, page, limit };
return { items: enriched, page, limit };
}
private calculateAge(birthDate: string): number {

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Delete, Get, Param, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiBody, ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { Public } from '../../common/decorators/public.decorator';
import { Roles } from '../../common/decorators/roles.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
@@ -16,7 +16,7 @@ export class GreetingsController {
@Public()
@Get()
@ApiOperation({ summary: 'Get all greeting phrases' })
@ApiResponse({ status: 200, type: [GreetingDto] })
@ApiOkResponse({ type: [GreetingDto] })
findAll() {
return this.greetingsService.findAll();
}
@@ -27,7 +27,7 @@ export class GreetingsController {
@Post()
@ApiOperation({ summary: 'Add greeting phrase (admin only)' })
@ApiBody({ schema: { type: 'object', properties: { text: { type: 'string', example: 'Привет!' } }, required: ['text'] } })
@ApiResponse({ status: 201, type: GreetingDto })
@ApiCreatedResponse({ type: GreetingDto })
create(@Body('text') text: string) {
return this.greetingsService.create(text);
}
@@ -37,7 +37,7 @@ export class GreetingsController {
@Roles('admin')
@Delete(':id')
@ApiOperation({ summary: 'Delete greeting phrase (admin only)' })
@ApiResponse({ status: 200, type: MessageResponseDto })
@ApiOkResponse({ type: MessageResponseDto })
delete(@Param('id') id: string) {
return this.greetingsService.delete(id);
}

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { CreateLikeDto } from './dto/create-like.dto';
@@ -15,14 +15,14 @@ export class LikesController {
@Post()
@ApiOperation({ summary: 'Like or dislike a profile' })
@ApiResponse({ status: 201, type: CreateLikeResponseDto })
@ApiCreatedResponse({ type: CreateLikeResponseDto })
createLike(@CurrentUser('id') userId: string, @Body() dto: CreateLikeDto) {
return this.likesService.createLike(userId, dto);
}
@Get('matches')
@ApiOperation({ summary: 'Get matches for a profile' })
@ApiResponse({ status: 200, type: [MatchDto] })
@ApiOkResponse({ type: [MatchDto] })
getMyMatches(
@CurrentUser('id') userId: string,
@Query('profileId') profileId: string,

View File

@@ -1,5 +1,5 @@
import { Controller, Delete, Get, Param, Post, Query, Req, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiConsumes, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiConsumes, ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { FastifyRequest } from 'fastify';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
@@ -17,7 +17,7 @@ export class MediaController {
@Post('upload')
@ApiOperation({ summary: 'Upload photo / video / audio to profile' })
@ApiConsumes('multipart/form-data')
@ApiResponse({ status: 201, type: MediaItemDto })
@ApiCreatedResponse({ type: MediaItemDto })
async upload(
@CurrentUser('id') userId: string,
@Param('profileId') profileId: string,
@@ -37,14 +37,14 @@ export class MediaController {
@Get()
@ApiOperation({ summary: 'Get all media for a profile' })
@ApiResponse({ status: 200, type: [MediaItemDto] })
@ApiOkResponse({ type: [MediaItemDto] })
getMedia(@Param('profileId') profileId: string) {
return this.mediaService.getByProfileId(profileId);
}
@Delete(':mediaId')
@ApiOperation({ summary: 'Delete media item' })
@ApiResponse({ status: 200, type: MessageResponseDto })
@ApiOkResponse({ type: MessageResponseDto })
deleteMedia(
@CurrentUser('id') userId: string,
@Param('mediaId') mediaId: string,

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Delete, Get, Param, Post, Put, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { CreateProfileDto } from './dto/create-profile.dto';
@@ -17,21 +17,21 @@ export class ProfilesController {
@Post()
@ApiOperation({ summary: 'Create a new profile (one user can have many)' })
@ApiResponse({ status: 201, type: ProfileResponseDto })
@ApiCreatedResponse({ type: ProfileResponseDto })
create(@CurrentUser('id') userId: string, @Body() dto: CreateProfileDto) {
return this.profilesService.create(userId, dto);
}
@Get('my')
@ApiOperation({ summary: 'Get all my profiles' })
@ApiResponse({ status: 200, type: [ProfileResponseDto] })
@ApiOkResponse({ type: [ProfileResponseDto] })
getMyProfiles(@CurrentUser('id') userId: string) {
return this.profilesService.findAllByUserId(userId);
}
@Put(':profileId')
@ApiOperation({ summary: 'Update profile by ID (must be owner)' })
@ApiResponse({ status: 200, type: ProfileResponseDto })
@ApiOkResponse({ type: ProfileResponseDto })
update(
@CurrentUser('id') userId: string,
@Param('profileId') profileId: string,
@@ -42,14 +42,14 @@ export class ProfilesController {
@Get(':profileId')
@ApiOperation({ summary: 'Get profile by ID' })
@ApiResponse({ status: 200, type: ProfileResponseDto })
@ApiOkResponse({ type: ProfileResponseDto })
findOne(@Param('profileId') profileId: string) {
return this.profilesService.findByProfileId(profileId);
}
@Delete(':profileId')
@ApiOperation({ summary: 'Delete profile (must be owner)' })
@ApiResponse({ status: 200, type: MessageResponseDto })
@ApiOkResponse({ type: MessageResponseDto })
delete(@CurrentUser('id') userId: string, @Param('profileId') profileId: string) {
return this.profilesService.delete(userId, profileId);
}

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { Roles } from '../../common/decorators/roles.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
@@ -17,7 +17,7 @@ export class ReportsController {
@Post()
@ApiOperation({ summary: 'Submit a report' })
@ApiResponse({ status: 201, type: ReportDto })
@ApiCreatedResponse({ type: ReportDto })
create(@CurrentUser('id') userId: string, @Body() dto: CreateReportDto) {
return this.reportsService.create(userId, dto);
}
@@ -26,7 +26,7 @@ export class ReportsController {
@Roles('admin', 'moderator')
@UseGuards(RolesGuard)
@ApiOperation({ summary: 'Get all reports (admin/moderator)' })
@ApiResponse({ status: 200, type: [ReportDto] })
@ApiOkResponse({ type: [ReportDto] })
getAll() {
return this.reportsService.getAll();
}

View File

@@ -1,5 +1,5 @@
import { Body, Controller, Delete, Get, Param, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiBody, ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { Public } from '../../common/decorators/public.decorator';
import { Roles } from '../../common/decorators/roles.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
@@ -16,7 +16,7 @@ export class TagsController {
@Public()
@Get()
@ApiOperation({ summary: 'Get all tags' })
@ApiResponse({ status: 200, type: [TagResponseDto] })
@ApiOkResponse({ type: [TagResponseDto] })
findAll() {
return this.tagsService.findAll();
}
@@ -27,7 +27,7 @@ export class TagsController {
@Post()
@ApiOperation({ summary: 'Create tag (admin only)' })
@ApiBody({ schema: { type: 'object', properties: { value: { type: 'string', example: 'Спорт' } }, required: ['value'] } })
@ApiResponse({ status: 201, type: TagResponseDto })
@ApiCreatedResponse({ type: TagResponseDto })
create(@Body('value') value: string) {
return this.tagsService.create(value);
}
@@ -37,7 +37,7 @@ export class TagsController {
@Roles('admin')
@Delete(':id')
@ApiOperation({ summary: 'Delete tag (admin only)' })
@ApiResponse({ status: 200, type: MessageResponseDto })
@ApiOkResponse({ type: MessageResponseDto })
delete(@Param('id') id: string) {
return this.tagsService.delete(id);
}

View File

@@ -1,5 +1,5 @@
import { Controller, Get, Param, Patch, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { Roles } from '../../common/decorators/roles.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
@@ -17,14 +17,14 @@ export class UsersController {
@Get('me')
@ApiOperation({ summary: 'Get current user with profile list' })
@ApiResponse({ status: 200, type: MeResponseDto })
@ApiOkResponse({ type: MeResponseDto })
getMe(@CurrentUser('id') userId: string) {
return this.usersService.getMe(userId);
}
@Get(':id')
@ApiOperation({ summary: 'Get user by ID' })
@ApiResponse({ status: 200, type: UserResponseDto })
@ApiOkResponse({ type: UserResponseDto })
findOne(@Param('id') id: string) {
return this.usersService.findById(id);
}
@@ -33,7 +33,7 @@ export class UsersController {
@Roles('admin', 'moderator')
@UseGuards(RolesGuard)
@ApiOperation({ summary: 'Ban user' })
@ApiResponse({ status: 200, type: MessageResponseDto })
@ApiOkResponse({ type: MessageResponseDto })
ban(@Param('id') id: string) {
return this.usersService.banUser(id);
}
@@ -42,7 +42,7 @@ export class UsersController {
@Roles('admin', 'moderator')
@UseGuards(RolesGuard)
@ApiOperation({ summary: 'Activate user' })
@ApiResponse({ status: 200, type: MessageResponseDto })
@ApiOkResponse({ type: MessageResponseDto })
activate(@Param('id') id: string) {
return this.usersService.activateUser(id);
}