오프팀 포트 번호 5006 번 입니다‼️‼️‼️‼️‼️
기본 요구 사항
API 안내
API Host는
https://kdt.frontend.4th.programmers.co.kr:5006
입니다.오프팀 포트 번호 5006 번 입니다‼️‼️‼️‼️‼️0. API에 추가적인 데이터가 필요한 경우1. 어드민 (공통)2. 채널 생성 방법 3. 인증4. 사용자5. 설정5. 채널5. 포스트6. 좋아요7. 댓글8. 알림9. 팔로우10. 메세지11. 검색12. 모델 안내UserChannelPostLikeCommentNotificationFollowConversationMessage
0. API에 추가적인 데이터가 필요한 경우
내용
- 필드에 사용자 정의 JSON 값을 넣어서 처리하는 방법을 사용할 수 있습니다.
- Post 모델에 제목과 내용을 분리하고 싶다면
title
필드에 사용자 정의 JSON을 String으로 변환하여 넣을 수 있습니다 - 간단한 의사 코드로 표현하자면 다음과 같습니다.
const json = { "title": "제목", "body": "내용" }; API.createPost(JSON.stringify(json), ...);
1. 어드민 (공통)
각 서버에 어드민 계정이 따로 있고, 공통적으로 다음 계정으로 생성됩니다
email: admin@programmers.co.kr password: programmers
2. 채널 생성 방법
내용
POST /channels/create
포스트를 남기기 위해서는 채널이 필요해서 채널 생성이 필요합니다.
채널 추가는 어드민 계정으로 가능하고 다음과 같이 요청을 보낼 수 있습니다.
Request Body
{ "authRequired": Boolean // 채널 내용을 로그인한 사람만 볼 수 있는지 여부 "description": String // 채널 설명 "name": String // 채널 이름 } (메모) 일단 authRequired: false로 해서, 클라이언트 단에서 토큰 여부로 체크할 수 있도로
3. 인증
로그인
회원 가입
사용자가 이메일과 비밀번호로 서비스에 가입합니다.
POST /signup
Request Body
{ "email": String, "fullName": String, //닉네임 "password": String }
Response
200 OK
{ "user": User, "token": String }
로그아웃
사용자가 로그아웃 합니다.
POST /logout
인증 확인 ⇒ 로그인 후 토근 줌
사용자가 인증이 되었는지 확인합니다.
GET /auth-user
Request Header
Authorization: bearer JWT토큰
Response
User
4. 사용자
사용자 목록
사용자 목록을 불러옵니다.
GET /users/get-users
Request Params
offset: Optional (시작점) limit: Optional (끝점)
Response
User[]
현재 접속 중인 사용자 목록
현재 접속 중인 사용자 목록을 불러옵니다.
GET /users/online-users
Response
User[]
사용자 정보
특정 사용자 정보를 불러옵니다.
GET /users/{userId}
Response
User
프로필 이미지 변경
커버 이미지 변경
5. 설정
내 정보 변경
비밀번호 변경
5. 채널
5. 포스트
특정 채널의 포스트 목록 불러오기
특정 사용자의 포스트 목록 불러오기
특정 채널에 포스트 작성하기
내가 작성한 포스트 수정하기
내가 작성한 포스트 삭제하기
6. 좋아요
특정 포스트 좋아요
특정 포스트 좋아요 취소
7. 댓글
특정 포스트에 댓글 달기
특정 포스트에 작성한 내 댓글 지우기
8. 알림
나의 알림 목록을 불러옵니다.
나에게 온 알림을 읽음처리 합니다.
상대방에게 알림을 보냅니다.
상대방에게 알림을 보냅니다.
POST /notifications/create
원래는 서버에서 해주는게 맞는 작업이지만 API 호출로 알림을 보낼 수 있도록 작성했습니다.
Request Header
Authorization: bearer JWT토큰
Request Body
notificationTypeId
는 type에 해당하는 객체의 id를 넣어주세요.- COMMENT일 경우엔 댓글 id
- FOLLOW일 경우엔 팔로우 id
- LIKE일 경우엔 좋아요 id
- MESSAGE일 경우엔 메시지 id
postId
는 type이 FOLLOW일 경우엔 null로 보내주세요.{ "notificationType": "COMMENT" | "FOLLOW" | "LIKE" | "MESSAGE", "notificationTypeId": String, "userId": String, "postId": Nullable<String> }
Response
Notification
9. 팔로우
특정 유저를 팔로우합니다.
특정 유저를 언팔합니다.
10. 메세지
나의 메시지함 (소통한 유저 목록)
특정 사용자와 소통한 메시지 목록
특정 사용자에게 메시지 전송
메시지 확인 처리
11. 검색
12. 모델 안내
API에 따라 모델 필드에서 일부분이 빠진 상태로 내려올 수 있습니다.
ex) 로그인 후 내려오는 User에는 프로필 이미지와 커버 이미지 필드가 제거됩니다.
User
{ "coverImage": String, // 커버 이미지 "image": String, // 프로필 이미지 "role": String, "emailVerified": Boolean, // 사용되지 않음 "banned": Boolean, // 사용되지 않음 "isOnline": Boolean, "posts": Post[], "likes": Like[], "comments": String[], "followers": [], "following": [ { "_id": "6169e91316cb2265df003c6d", "user": "6169e58216cb2265df003bf4", "follower": "6169e206aa57d952c6dc1edd", "createdAt": "2021-10-15T20:48:19.816Z", "updatedAt": "2021-10-15T20:48:19.816Z", "__v": 0 } ], "notifications": Notification[], "messages": Message[], "_id": String, "fullName": String, "email": String, "createdAt": String, "updatedAt": String }
Channel
{ "authRequired": Boolean, // 사용되지 않음 "posts": String[], "_id": String, "name": String, "description": String, "createdAt": String, "updatedAt": String }
Post
{ "likes": Like[], "comments": Comment[], "_id": String, "image": Optional<String>, "imagePublicId": Optional<String>, "title": String, "channel": Channel, "author": User, "createdAt": String, "updatedAt": String }
Like
{ "_id": String, "user": String, // 사용자 id "post": String, // 포스트 id "createdAt": String, "updatedAt": String }
Comment
{ "_id": String, "comment": String, "author": User, "post": String, // 포스트 id "createdAt": String, "updatedAt": String }
Notification
{ "seen": Boolean, "_id": String, "author": User, "user": User | String, "post": Nullable<String>, // 포스트 id "follow": Optional<String>, // 사용자 id "comment": Optional<Comment>, "message": Optional<String>, // 메시지 id "createdAt": String, "updatedAt": String }
Follow
{ "_id": String, "user": String, // 사용자 id "follower": String, // 사용자 id "createdAt": String, "updatedAt": String }
Conversation
{ "_id": String[], "message": String, "sender": User, "receiver": User, "seen": Boolean, "createdAt": String }
Message
{ "_id": String, "message": String, "sender": User, "receiver": User, "seen": Boolean, "createdAt": String, "updatedAt": String }