# API 설계
<img src="https://user-images.githubusercontent.com/33643752/99625518-c898e100-2a73-11eb-9e77-182bfdbbc921.png"/>
- 요청 URL
- 설명
- Method
- REQUEST
- Header
- Body
- RESPONSE
- Header
- Body
### 공통 URL
- localhost:3000/api
### User
- 회원 가입
- method : POST
- /users/signup
- request
```
{
id : "string",
password : "string",
displayName : "string",
fullName : "string",
profileUri : "string"
}
```
- 로그인
- method : POST
- /users/signin
- 소셜 로그인
- method : GET
- /oauth/github/login
- github페이지로 이동시켜주는 API
- 소셜 콜백
- method : GET
- /oauth/github/callback
- 인증을 받고 나서 callback 함수가 실행되고 token 발생, DB 넣어주고
- 모든 유저 조회
- method : GET
- /users
- request
- response
```
"code" : 200,
{
userCount: "number",
users : [
userId: "number",
displayName: "string",
profileUri: "string"
]
}
```
- 단일 유저 조회
- method: GET
- /users/:userId
- request
- response
```
"code" : 200,
{
userId : "number",
"id" : "string",
"profileUrl" : "string",
"fullName": "string"
"displayName" : "string",
"whatIDo" : "string",
"phoneNumber": "string"
}
```
- 프로필 수정
- method : PATCH
- /users
- request
```
{
"profileUrl" : "string",
"fullName": "string"
"displayName" : "string",
"whatIDo" : "string",
"phoneNumber": "string"
}
```
- response
```
"code" : 201
```
- 회원 탈퇴
- method : DELETE
- /users
- request
- response
```
"code" : 204
```
### UserChatRoom
- 본인이 참여한 채팅방 조회
- 본인이 참여한 모든 채팅방을 사이드바에 띄우기 위해 조회
- method : GET
- /user-chatrooms
- request
- respose
```
"code" : 200
{
[
"sectionId" : "number",
"sectionName" : "string",
"chatRoom" : [
"chatRoomId" : number,
"title" : string,
"isPrivate" : boolean,
"chatType" : string
]
]
}
```
- 채팅방 본인 조인
- 사용자 본인이 입장
- method : POST
- /user-chatrooms
- request
```
{
"chatRoomId": "number",
}
```
- response
```
"code" : 201
```
- 채팅방 User 초대하기
- 여러 사용자 가능하게
- method : POST
- /user-chatrooms/others
- request
```
{
"users" : ["number"],
"chatRoomId": "number",
}
```
- response
```
"code" : 201
```
- 채팅방 떠나기
- method : DELETE
- /user-chatrooms/:chatroomId
- request
- response
```
"code" : 204
```
- 채팅방 정보(섹션, 알람) 변경하기
- method : PATCH
- /user-chatrooms/:chatroomId
- request
```
{
"sectionName": "string",
"alarm": "boolean"
}
```
- response
```
"code" : 201
```
### section
- 섹션 만들기
- method : POST
- /section
- request
```
{
"sectionName": "string"
}
```
- response
```
"code" : 201
```
- 섹션 수정
- method : PATCH
- /section/:sectionId
- request
```
{
"sectionName": "string"
}
```
- response
```
"code" : 201
```
- 섹션 삭제
- method : DELETE
- /section/:sectionId
- request
- response
```
"code" : 201
```
### ChatRoom
- 채널 / DM 생성
- method : POST
- /chatrooms
- request
```
{
"title" : string,
"isPrivate" : boolean,
"chatTypd" : "string",
"topic" : "string"
}
```
- response
```
"code" : 201
```
- 채팅방 필터링 조회
- method : GET
- /chatrooms?private= "boolean"&hideMyChannels="boolean"&keyword="string"
- All, Private, hideMyChannels, 검색어
- request
- response
```
{
chatRooms :[
"id": number,
"title": string,
"members" : number,
"description": string
"isPrivate": boolean
]
}
```
추후 분리 요망
- 채팅방 정보(메시지, 댓글, 참여자) 조회
- method : GET
- /chatrooms/:chatroomId
- request
- response
```
"code": 200
{
"title": string,
"description": string,
"isPrivate": boolean,
"chatType": string,
"topic": string
"messages" : [
"messageId": number,
"createAt": date,
"updatedAt": date,
"content": string,
"user":{
"userId": number,
"profileUrl": string,
"displayName"" string,
},
messageReactions:[
"title": string
"imageUri": string,
"replyDisplayNames": ["string"]
]
"thread":{
"replyCount": number,
"lastReplyAt": date,
prifileUrls:[
profileUrl:string
]
},
"files": {
"fileId": number,
"fileUri": string,
}
],
"userCount": number,
"users" : [
"userId": number,
"profileUrl": string,
"displayName"" string,
],
"files":[
"fileId": number,
"fileUri": string
]
}
```
- 채팅방 정보 변경
- method : PATCH
- /chatrooms/:chatroomId
- request
```
{
"topic" : string,
"description": string
}
```
- response
```
"code": 201
```
- 채팅방 삭제
- method : DELETE
- /chatrooms/:chatroomId
- request
- response
```
"code": 204
```
### Message
- 메시지 생성
- method : POST
- 파일
- /messages
- request
```
{
"content": string,
"chatRoomId": number,
"fileUri": string
}
```
- response
```
"code": 201
```
- 메시지 단일 조회
- method : GET
- /messages/:messageId
- request
- response
```
"code": 200
{
"messageId": number,
"createAt": date,
"updatedAt": date,
"content": string,
"user":{
"userId": number,
"profileUrl": string,
"displayName"" string,
},
messageReactions:[
"title": string
"imageUri": string,
"replyDisplayNames": ["string"]
]
"thread":{
"replyCount": number,
"lastReplyAt": date,
prifileUrls:[
profileUrl:string
]
},
"files": {
"fileId": number,
"fileUri": string,
}
}
```
- 메시지 수정
- method : PATCH
- /messages/:messageId
- request
```
{
"content": string,
"fileUri": string
}
```
- response
```
"code": 201
```
- 메시지 삭제
- method : DELETE
- /messages/:messageId
- request
- response
```
"code": 204
```
### File
- 파일 생성
- method : POST
- /files
- request
```
{
"fileUri": string,
"messageId": number
}
```
- response
```
"code": 201
```
- 파일 삭제
- method : DELETE
- /files/:fileId
- request
- response
```
"code": 204
```
### object storage
- 파일 삽입
- method : POST
- /object-storage
- request
```
file
```
- response
```
"code": 204
{
"fileUri":string
}
```
### Reaction
- 리액션 생성
- method : POST
- /reactions
- object storage
- request
```
{
"title": string,
"imageUri": string
}
```
- response
```
"code" : 201
```
- 리액션 전체 조회
- method : GET
- /reactions
- request
- response
```
"code": 200
{
reactions:[
"reactionId" : number,
"title": string,
"imageUri": string,
]
}
```
### MessageReaction
- 메시지에 리액션 추가
- method : POST
- /message-reactions
- request
```
{
"messageId": number,
"reactionId": number,
}
```
- response
```
"code": 201
```
- 메시지에 리액션 제거
- method : DELETE
- /message-reactions/:messageId/:reactionId
- request
- response
```
"code": 204
```
### Reply
- 댓글 생성
- method : POST
- 파일
- /replies
- request
```
{
"messageId": number,
"chatRoomId": number,
"content": string,
"fileUri": string
}
```
- response
```
"code": 201
```
- 댓글 전체 조회
- method : GET
- /replies
- request
- response
```
"code" : 200
{
"replies" : [
"replyId": number,
"createAt": date,
"updateAt": date,
"content": string,
"user":{
"userId": number,
"profileUrl": string,
"displayName"" string,
},
replyReactions:[
"title": string
"imageUri": string,
"replyDisplayNames": ["string"]
]
"file": {
"fileId": number,
"fileUri": string,
}
],
}
```
- 댓글 단일 조회
- method : GET
- /replies/:replyId
- request
- response
```
"code": 200
{
"replyId": number,
"createAt": date,
"updateAt": date,
"content": string,
"user":{
"userId": number,
"profileUrl": string,
"displayName"" string,
},
replyReactions:[
"title": string
"imageUri": string,
"replyDisplayNames": ["string"]
]
"file": {
"fileId": number,
"fileUri": string,
}
}
```
- 댓글 수정
- method : PATCH
- /replies/:replyId
- request
```
{
"content": string,
"fileUri": string
}
```
- response
```
"code" : 201
```
- 댓글 삭제
- method : DELETE
- /replies/:replyId
- request
- response
```
"code" : 204
```
### ReplyReaction
- 댓글에 리액션 추가
- method : POST
- /reply-reactions
- request
```
{
"replyId": number,
"reactionId": number,
}
```
- response
```
"code": 201
```
- 댓글에 리액션 제거
- method : DELETE
- /reply-reactions/:replyId/:reactionId
- request
- response
```
"code": 204
```
<!-- ### threads << 우선순위를 많이 미뤄서 놓고
- 쓰레드 조회
- method : GET
- /threads
- request
```
{}
```
- response
```
{}
```
### mentions & reactions
- 멘션 & 리액션 조회
- method : GET
- /mention-reactions
- request
```
{}
```
- response
```
{}
``` -->