API ENDPOINT: http://kdt.frontend.2nd.programmers.co.kr:5002/
❓ JWT 토큰 저장 방식
❓ 지금 API로 찬성/반대를 어떤 방식으로 구현할 수 있을지
기본 요구사항
사용자는 회원가입과 로그인을 할 수 있습니다.
사용자는 채널에 올라온 글을 볼 수 있습니다.
사용자는 가입자 목록을 볼 수 있습니다.
사용자는 가입자를 이름으로 검색을 할 수 있습니다.
사용자는 가입자의 정보를 볼 수 있습니다.
사용자는 포스트 혹은 가입자를 검색할 수 있습니다.
인증된 사용자는 자신의 정보를 변경할 수 있습니다.
인증된 사용자는 채널에 올라온 글을 볼 수 있습니다.
인증된 사용자는 채널에 포스트를 남길 수 있습니다.
인증된 사용자는 포스트를 좋아요 할 수 있습니다.
인증된 사용자는 포스트에 댓글을 남길 수 있습니다.
인증된 사용자는 자신의 알림 목록을 확인 할 수 있습니다.
SPA 형태로 만들어주세요.
엉뚱한 페이지에 접속하면 404 페이지를 보여주세요.
인증
Token 유무파악 ⇒ X ⇒ 로그인 ⇒ 토큰(쿠키), 유저(상태)
새로고침 ⇒ 토큰(있으면) ⇒ get 유저 정보 받아오고, 상태 저장(전역 상태관리, context API ) 하고 ⇒ 유저 정보를 보여주게되면 가져온 정보를 기반으로 프로필 사진 같은 것을 뿌려준다.
- 로그인
- Request Body
이메일과 비밀번호로 서비스 로그인
POST /login
{ "email": String, "password": String }
{ "user": User, "token": String }
- 회원가입
- Request Body
이메일과 비밀번호로 서비스 가입
POST /signup
{ "email": String, "fullName": String, "password": String }
{ "user": User, "token": String }
- 인증 확인
- Request Header
사용자가 인증 되었는지 확인
GET /auth-user
Authorization: bearer JWT 토큰
User
- 로그아웃
사용자가 로그아웃
POST /logout
사용자
- 사용자 목록 ( 🍅 테스트 안됐음! 어드민 계정만 뜸 ⇒ 가장 최근 생성 계정이 안뜨는듯? ⇒ 그것도 아니고 그냥 랜덤으로 안뜸 🍅)
- Request Params (아마 쿼리스트링인듯?)
사용자 목록 불러오기
GET /users/get-users
offset: Optional<Number> limit: Optional<Number>
User[]
- 현재 접속 중인 사용자 목록 ( 🍅 테스트 안됐음! 어드민 계정만 뜸 ⇒ 다른게 뜨긴 하는데 접속중의 의미가 머지🍅) 이거는 본인 외에 접속 중인 사용자를 보여주는 것 같음.
- Response
접속 중인 사용자 목록 불러오기
GET /users/online-users
User[]
- 사용자 정보
- Response
특정 사용자 정보 불러오기
GET /users/{userId}
User
- 프로필 이미지 변경
- Request Header
내 프로필 이미지 변경
POST /users/upload-photo
Authorization: bearer JWT토큰
isCover
는 반드시 false
// FormData isCover: false image: Binary
User
- 커버 이미지 변경
- Request Header
내 커버 이미지 변경
POST /users/upload-photo
Authorization: bearer JWT토큰
// FormData isCover: true image: Binary
User
설정
- 내 정보 변경
- Request Header
PUT /settings/update-user
Authorization: bearer JWT토큰
{ "fullName": String, "username": String }
User
- 비밀번호 변경
- Request Header
내 계정 비밀번호 변경
PUT /settings/update-password
Authorization: bearer JWT토큰
{ "password": String }
채널 (일단은 단일 채널로. 꼭 여러 개 추가해야하면 자유게시판 정도?)
- 채널 목록
- Response
채널 목록 불러오기
GET /channels
Channel[]
- 채널 정보
- Response
특정 채널 정보 가져오기
GET /channels/{channelName}
Channel
포스트
- 특정 채널의 포스트 목록
- Request Params
특정 채널 포스트 목록 불러오기
GET /posts/channel/{channelId}
offset: Optional<Number> limit: Optional<Number>
Post[]
- 특정 사용자의 포스트 목록
- Request Params
특정 사용자 포스트 목록 불러오기
GET /posts/author/{authorId}
offset: Optional<Number> limit: Optional<Number>
Post[]
- 특정 채널에 포스트 작성
- Request Header
POST /posts/create
Authorization: bearer JWT토큰
// FormData title: String, image: Binary | null channelId: String
- 특정 포스트 상세 보기
- Response
GET /posts/{postId}
Post
- 내가 작성한 포스트 수정
- Request Header
PUT /posts/update
Authorization: bearer JWT토큰
// FormData postId: String title: String image: Binary | null imageToDeletePublicId: Optional<String> channelId: String
이미지를 삭제하려면
imageToDeletePublicId
에 imagePublicId
전달- 내가 작성한 포스트 삭제
- Request Header
DELETE /posts/delete
Authorization: bearer JWT토큰
{ "id": String }
좋아요
- 특정 포스트 좋아요
- Request Header
POST /likes/create
Authorization: bearer JWT토큰
{ "postId": String }
Like
- 특정 포스트 좋아요 취소
- Request Header
DELETE /likes/delete
Authorization: bearer JWT토큰
{ "id": String // likes 아이디임 }
Like
댓글
- 특정 포스트에 댓글 달기
- Request Header
POST /comments/create
Authorization: bearer JWT토큰
{ "comment": String, "postId": String }
Comment
- 특정 포스트에 작성한 내 댓글 지우기
- Request Header
DELETE /comments/delete
Authorization: bearer JWT토큰
{ "id": String }
Comment
알림
- 나의 알림 목록 (🍅 알림 생성이 안돼서 테스트 못함)
- Request Header
알림 목록 불러오기
GET /notifications
Authorization: bearer JWT토큰
Notification[]
- 알림 확인 처리(🍅 알림 생성이 안돼서 테스트 못함)
- Request Header
나에게 온 알림 읽음 처리
PUT /notifications/seen
Authorization: bearer JWT토큰
- 알림 생성 (🍅 아예 전송이 안되는듯? 그리고 “MESSAGE” 일 때 postId 값은 뭘로?)
- Request Header
상대방에게 알림 전송
POST /notifications/create
Authorization: bearer JWT토큰
{ "notificationType": "COMMENT" | "LIKE" "notificationTypeId": String, // COMMENT id || LIKE id "userId": String, // 해당 포스트 주인 아이디 || 해당 포스트 주인의 아이디 "postId": Nullable<String> //해당 포스트의 id }
notificationTypeId
는 notificationType
에 해당하는 객체의 id 입력notificationType
이 FOLLOW
이면 postId
값은 null
로 보내야함Notification
팔로우
- 특정 유저 팔로우
- Request Header
POST /follow/create
Authorization: bearer JWT토큰
{ "userId": String }
Follow
- 특정 유저 언팔로우
- Request Header
DELETE /follow/delete
Authorization: bearer JWT토큰
{ "id": String }
Follow
메시지 (기본 요구사항은 아님)
- 나의 메시지함 (소통한 유저 목록)
- Request Header
GET /messages/conversations
Authorization: bearer JWT토큰
Conversation[]
- 특정 사용자와 소통한 메시지 목록 (🍅 이거 안됨, 빈 배열만 반환됨)
- Request Header
GET /messages
Authorization: bearer JWT토큰
userId: String
Message[]
- 특정 사용자에게 메시지 전송
- Request Header
POST /messages/create
Authorization: bearer JWT토큰
{ "message": String, "receiver": String // 사용자 id }
Message
- 메시지 확인 처리
- Request Header
특정 사용자와 나눈 메시지 읽음처리
PUT /messages/update-seen
Authorization: bearer JWT토큰
{ "sender": String // 사용자 id }
검색
query가 뭘 의미하는걸까… 그냥 검색 문자열이겠지?
- 사용자 검색
GET /search/users/{query}
- Response
User[]
- 전체 검색 (포스트, 사용자 한꺼번에?)
- 포스트, 사용자(fullName) 검색 → 대/소문자 구별x
- title 내부 프로퍼티는 예약어로, 검색되지 않도록 제외
- Response
GET /search/all/{query}
(User | Post)[]
모델 안내
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 }
Post - Custom Object
Post { "title" : { "postTitle": string, "postContent": string, "agreeContent": string, "disagreeContent": 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 }
Comment - Custom Object
Comment { "comment": { "type": string, // 'agree', 'disagree', 'vote' "content": string // 댓글 내용 }, //vote 일때 "comment": { "type": "vote", "content": "agree" || "disagre" }, }
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 }