API
Each of services need a token within their args for authorization
User Services
handle user and its authorization both on REST API and websocket.
postLoginUser
user login
declare const postLoginUser: (body: ILoginBody, token?: string) => Promise<axios.AxiosResponse<ILoginResponse, any>>;
getDetailUser
retrieve user detail of current user
declare const getDetailUser: (user_id: string, token?: string) => Promise<axios.AxiosResponse<IGetDetailUserResponse, any>>;
getUsers
retrieve list of users
declare const getUsers: (params?: IGetUsersParams, token?: string) => Promise<axios.AxiosResponse<IGetUsersResponse, any>>;
getUsersPagination
retrieve users with pagination
declare const getUsersPagination: (params?: IGetUsersPaginationParams, token?: string) => Promise<axios.AxiosResponse<IGetUsersPaginationResponse, any>>;
handleLogin
wrap postLoginUser
that return mapped object. Recommended to utilize this function to handle user login.
declare const handleLogin: (uname: string, passwd: string) => Promise<{
token: string;
current_user_id: string;
current_username: string;
}>;
Room Services
getDetailRoom
detail of each room
declare const getDetailRoom: (room_id: string, token?: string) => Promise<axios.AxiosResponse<IGetDetailRoomResponse, any>>;
getRooms
list of rooms
declare const getRooms: (params?: IGetRoomsParams, token?: string) => Promise<axios.AxiosResponse<IGetRoomsResponse, any>>;
getRoomsPagination
list of rooms with pagination
declare const getRoomsPagination: (params?: IGetRoomsPaginationParams, token?: string) => Promise<axios.AxiosResponse<IGetRoomsPaginationResponse, any>>;
postCreateRoom
create a room
declare const postCreateRoom: (body: IPostCreateRoomBody, token?: string) => Promise<axios.AxiosResponse<IPostCreateRoomResponse, any>>;
deleteDeleteRoom
delete a room
declare const deleteDeleteRoom: (room_id: string, token?: string) => Promise<axios.AxiosResponse<IDeleteDeleteRoomResponse, any>>;
socketJoinNewRoom
Emit join new room. Join from sender side. Recommended
declare const socketJoinNewRoom: (socket: Socket, body: ISocketJoinRoomBody) => void;
onCreateNewRoom
wrappostCreateRoom
with socketJoinNewRoom
. Recommended
declare const onCreateNewRoom: (socket: Socket, apiBody: IPostCreateRoomBody, token?: string) => Promise<{
api_res: axios.AxiosResponse<IPostCreateRoomResponse, any>;
}>;
onListenReceiveNewRoom
Socket listener for new room. It includes to emit again joinNewRoom
in order to join receiver side to socket system. Recommended
declare const onListenReceiveNewRoom: (socket: Socket, mainState: IMainRoomsState[], setMainState: Dispatch<SetStateAction<IMainRoomsState[]>>, data: ISocketReceiveJoinNewRoom, currentUser: IUser) => void;
onEmitWritting
Emit i'm writting status. Recommended
declare const onEmitWritting: (socket: Socket, body: ISocketWrittingBody) => void;
onListenWrittingRoom
Sokcet listener for i'm writting. Recommended
declare const onListenWrittingRoom: (mainState: IMainRoomsState[], setMainState: Dispatch<SetStateAction<IMainRoomsState[]>>, data: any, currentUser: IUser) => void;
Message Services
getMessages
Retrieve list of messages
declare const getMessages: (params: IGetMessagesParams, token?: string) => Promise<axios.AxiosResponse<IGetMessagesResponse, any>>;
getMessagesPagination
Retrieve list of messages with pagination
declare const getMessagesPagination: (params: IGetMessagesPaginationParams, token?: string) => Promise<axios.AxiosResponse<IGetMessagesPaginationResponse, any>>;
postCreateMessage
Create a message
declare const postCreateMessage: (body: IPostCreateMessageBody, token?: string) => Promise<axios.AxiosResponse<IPostCreateMessageResponse, any>>;
onCreateMessage
wrap postCreateMessage
and socket emit sendMessage
. Recommended
declare const onCreateMessage: (socket: Socket, apiBody: IPostCreateMessageBody, token?: string) => Promise<{
api_res: axios.AxiosResponse<IPostCreateMessageResponse, any>;
}>;
onListenMessage
Socket listener for a new message. Recommended
declare const onListenMessage: (mainState: IMainRoomsState[], setMainState: Dispatch<SetStateAction<IMainRoomsState[]>>, message?: ISocketMessage, currentUser?: IUser) => void;
onEmitViewUnreadMessage
Socket emit for view unread message. Recommended
declare const onEmitViewUnreadMessage: (socket: Socket, mainState: IMainRoomsState[], setMainState: Dispatch<SetStateAction<IMainRoomsState[]>>, room_id: string, currentUser?: IUser) => void;
onListenReceiveUnreadMessage
Socket listener for receive view unread message. Recommended
declare const onListenReceiveUnreadMessage: (mainState: IMainRoomsState[], setMainState: Dispatch<SetStateAction<IMainRoomsState[]>>, selectedRoom: string, data: ISocketReceiveUnreadMessage, currentUser?: IUser) => void;
onEmitImOnline
Socket emit for i'm online. Recommended
declare const onEmitImOnline: (socket: Socket, body: ISocketImOnlineBody) => void;
onListenReceiveImOnline
Socket listener for i'm online. Recommended
declare const onListenReceiveImOnline: (mainState: IMainRoomsState[], setMainState: Dispatch<SetStateAction<IMainRoomsState[]>>, data?: ISocketReceiveImOnline, currentUser?: IUser) => void;
Upload Services
uploadSingle
upload for single file
declare const uploadSingle: (body: FormData, token?: string) => Promise<axios.AxiosResponse<{
data: IUpload;
}, any>>;
uploadMultiple
upload for multiple file
declare const uploadMultiple: (body: FormData, token?: string) => Promise<axios.AxiosResponse<{
data: IUpload[];
}, any>>;
Last updated