Skip to content

Commit

Permalink
�merge :: 채팅 api
Browse files Browse the repository at this point in the history
�merge :: 채팅 api
  • Loading branch information
Woonseok105 authored Mar 19, 2024
2 parents d41702b + eb2f3f2 commit 6552034
Show file tree
Hide file tree
Showing 13 changed files with 506 additions and 10 deletions.
168 changes: 168 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"@nestjs/jwt": "^10.2.0",
"@nestjs/passport": "^10.0.3",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/platform-socket.io": "^10.3.3",
"@nestjs/typeorm": "^10.0.2",
"@nestjs/websockets": "^10.3.3",
"aws-sdk": "^2.1574.0",
"bcrypt": "^5.1.1",
"class-validator": "^0.14.1",
Expand Down
4 changes: 3 additions & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import { TypeormConfigModule } from './infrastructure/global/config/typeorm.conf
import { ConfigModule } from '@nestjs/config';
import { UserModule } from './infrastructure/global/module/user.module';
import { AuthModule } from './infrastructure/global/module/auth.module';
import { EmojiModule } from "./infrastructure/global/module/emoji.module";
import { EmojiModule } from './infrastructure/global/module/emoji.module';
import { ChatModule } from './infrastructure/global/module/chat.module';
import { EventModule } from './infrastructure/global/module/event.module';

@Module({
imports: [
AuthModule,
UserModule,
EmojiModule,
ChatModule,
EventModule,
TypeormConfigModule,
ConfigModule.forRoot({ isGlobal: true })
]
Expand Down
32 changes: 32 additions & 0 deletions src/application/domain/chat/controller/chat.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
import { ChatService } from '../service/chat.service';
import { AuthGuard } from '@nestjs/passport';
import { CurrentUser } from '../../../../infrastructure/global/decorator/current-user';
import { UserEntity } from '../../../../infrastructure/domain/user/persistence/user.entity';
import { QueryChatMessageList, QueryJoinRoomsListResponse, RandomRoomResponse } from '../dto/chat.dto';

@Controller('chat')
export class ChatController {
constructor(
private readonly chatService: ChatService
) {
}

@Post('random')
@UseGuards(AuthGuard())
async createRandomRoom(@CurrentUser() user: UserEntity): Promise<RandomRoomResponse> {
return this.chatService.createRandomRoom(user);
}

@Get('rooms')
@UseGuards(AuthGuard())
async queryJoinedRooms(@CurrentUser() user: UserEntity): Promise<QueryJoinRoomsListResponse> {
return this.chatService.queryJoinRooms(user);
}

@Get('/messages/:id')
@UseGuards(AuthGuard())
async queryChatMessages(@Param() id: string, @CurrentUser() user: UserEntity): Promise<QueryChatMessageList> {
return this.chatService.queryChatMessage(id, user);
}
}
24 changes: 24 additions & 0 deletions src/application/domain/chat/dto/chat.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export class RandomRoomResponse {
roomId: string;
chatPartner: string;
}

export class QueryJoinRoomsListResponse {
rooms: RoomsList[];
}

export class RoomsList {
chatRoomId: string;
userProfile: string;
nickname: string;
alreadyRead: boolean;
}

export class QueryChatMessageList {
chatMessages: MessageList[];
}

export class MessageList {
message: string;
myMessage: boolean;
}
Loading

0 comments on commit 6552034

Please sign in to comment.