-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
175 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import callApi from '../../utils/api'; | ||
|
||
export type getFavoritesRes = { | ||
result: 1 | -1; | ||
favorites: string[]; | ||
}; | ||
export const getFavorites = function () { | ||
return callApi.get<{}, getFavoritesRes>(`users/favorites`); | ||
}; | ||
|
||
export type patchFavoritesReq = { | ||
favorites: string[]; | ||
}; | ||
export type patchFavoritesRes = { | ||
result: 1 | -1; | ||
favorites: string[]; | ||
}; | ||
export const patchFavorites = function (req: patchFavoritesReq) { | ||
return callApi.patch<patchFavoritesReq, patchFavoritesRes>( | ||
`users/favorites`, | ||
req, | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import callApi from '../../utils/api'; | ||
|
||
export type getRoomRes = { | ||
result: 1 | -1; | ||
room: string[]; | ||
}; | ||
export const getRoom = function () { | ||
return callApi.get<{}, getRoomRes>(`users/room`); | ||
}; | ||
|
||
export type patchRoomReq = { | ||
room: string[]; | ||
}; | ||
export type patchRoomRes = { | ||
result: 1 | -1; | ||
room: string[]; | ||
}; | ||
export const patchRoom = function (req: patchRoomReq) { | ||
return callApi.patch<patchRoomReq, patchRoomRes>(`users/room`, req); | ||
}; | ||
|
||
export type message = { | ||
_id: string; | ||
writer: string; | ||
contents: string; | ||
date: Date; | ||
read: number; | ||
}; | ||
export type getRoomByJwtAndIdxRes = { | ||
result: 1 | -1; | ||
_id: string; | ||
users: string[]; | ||
messages: message[]; | ||
}; | ||
export const getRoomByJwtAndIdx = function (_id: string) { | ||
return callApi.get<{}, getRoomByJwtAndIdxRes>(`rooms/user/${_id}`); | ||
}; | ||
|
||
export type addMessageInRoomReq = { | ||
contents: string; | ||
}; | ||
export type addMessageInRoomRes = { | ||
result: 1 | -1; | ||
_id: string; | ||
users: string[]; | ||
messages: message[]; | ||
}; | ||
export const addMessageInRoom = function ( | ||
_id: string, | ||
req: addMessageInRoomReq, | ||
) { | ||
return callApi.post<addMessageInRoomReq, addMessageInRoomRes>( | ||
`rooms/${_id}`, | ||
req, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import socketio from 'socket.io-client'; | ||
import callCookie from './cookie'; | ||
|
||
export default { | ||
connect: () => | ||
socketio.connect( | ||
`${process.env.REACT_APP_API_URL?.replace( | ||
'/api/', | ||
'', | ||
)}?auth=${callCookie.get('jwt')}`, | ||
), | ||
disconnect: (socket: SocketIOClient.Socket) => socket.disconnect(), | ||
}; |