HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
프로그래머스 프론트엔드 데브코스 2기
프로그래머스 프론트엔드 데브코스 2기
/
💣
🎉나영팀
/
🍅
API 정리
🍅

API 정리

 

API ENDPOINT: http://kdt.frontend.2nd.programmers.co.kr:5002/

 
❓ JWT 토큰 저장 방식
 
❓ 지금 API로 찬성/반대를 어떤 방식으로 구현할 수 있을지

기본 요구사항

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