Skip to content

Commit 645d3eb

Browse files
authored
Merge pull request #289 from WeGo-Together/hwanwook-feat/chat-api
[Feat] 채팅방 조회, DM 채팅방 생성, 웹소켓 연결 API 작업
2 parents 7cf4fbb + c0b9626 commit 645d3eb

File tree

21 files changed

+621
-258
lines changed

21 files changed

+621
-258
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
},
4545
"dependencies": {
4646
"@rehookify/datepicker": "^6.6.8",
47+
"@stomp/stompjs": "^7.2.1",
4748
"@tanstack/react-form": "^1.27.0",
4849
"@tanstack/react-query": "^5.90.3",
4950
"@tanstack/react-query-devtools": "^5.90.2",
@@ -57,6 +58,7 @@
5758
"react": "19.2.3",
5859
"react-daum-postcode": "^3.2.0",
5960
"react-dom": "19.2.3",
61+
"sockjs-client": "^1.6.1",
6062
"swiper": "^12.0.3",
6163
"tailwind-merge": "^3.3.1",
6264
"zod": "^4.1.13"
@@ -81,6 +83,7 @@
8183
"@types/node": "^20",
8284
"@types/react": "^19",
8385
"@types/react-dom": "^19",
86+
"@types/sockjs-client": "^1.5.4",
8487
"@types/webpack": "^5.28.5",
8588
"@typescript-eslint/eslint-plugin": "^8.46.1",
8689
"@typescript-eslint/parser": "^8.46.1",

pnpm-lock.yaml

Lines changed: 91 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
authServiceRemote,
3+
chatServiceRemote,
34
followerServiceRemote,
45
groupServiceRemote,
56
notificationServiceRemote,
@@ -12,13 +13,15 @@ const provideAPIService = () => {
1213
const followerService = followerServiceRemote();
1314
const notificationService = notificationServiceRemote();
1415
const groupService = groupServiceRemote();
16+
const chatService = chatServiceRemote();
1517

1618
return {
1719
userService,
1820
authService,
1921
followerService,
2022
notificationService,
2123
groupService,
24+
chatService,
2225
};
2326
};
2427

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { apiV1 } from '@/api/core';
2+
import {
3+
ChattingRoom,
4+
CreateDMPayloads,
5+
GetChatMessagesParams,
6+
GetChatMessagesResponse,
7+
GetChatRoomsResponse,
8+
} from '@/types/service/chat';
9+
10+
export const chatServiceRemote = () => ({
11+
// 채팅방 목록 조회
12+
getChatRooms: async () => {
13+
return apiV1.get<GetChatRoomsResponse>('/chat/rooms');
14+
},
15+
16+
// 1:1(DM) 채팅방 생성
17+
createDMChatRoom: async (payloads: CreateDMPayloads) => {
18+
return apiV1.post<ChattingRoom>('/chat/dm', payloads);
19+
},
20+
21+
// 메세지 이력 조회
22+
getChatMessages: async ({ roomId, cursor, size }: GetChatMessagesParams) => {
23+
return apiV1.get<GetChatMessagesResponse>(`/chat/rooms/${roomId}/messages`, {
24+
params: {
25+
cursor,
26+
size,
27+
},
28+
});
29+
},
30+
});

src/api/service/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './auth-service';
2+
export * from './chat-service';
23
export * from './follower-service';
34
export * from './group-service';
45
export * from './notification-service';

0 commit comments

Comments
 (0)