Skip to content

API 명세

woorimIT edited this page Jun 26, 2021 · 13 revisions

API 명세


🏡 홈

전체 조회

홈 화면에서 조회될 전체 데이터를 응답한다.
URL: /api/home
METHOD: GET

  • Response
    • Status: 200 OK
    • Content-Type: application/json
{
   lists: [{
      no: 13,
      title: "ToDo",
      cards: [{
         no: 1,
         content: "1일 1커밋",
         position: 1, // 카드 위치 순서
      }, {
         no: 3,
         content: "문서 정리",
         position: 2,
      }]
   }, {
      no: 21,
      title: "InProgress",
      cards: [{
         no: 2,
         content: "1일 1회화",
         position: 3,
      }, {
         no: 3,
         content: "API 명세 정리",
         position: 4,
      }]
   }]
}

📑 리스트

리스트 추가

URL: /api/list
METHOD: POST

  • Request
    • Content-Type: application/json
{
   title: "ToDo"
}
  • Response
    • Status: 201 Created
    • Content-Type: application/json
{
   result: "success",
   no: 1 // insertId (생성된 아이디)
}

🔖 카드

카드 추가

URL: /api/card
METHOD: POST

  • Request
    • Content-Type: application/json
{
   listNo: 1,
   content: "1일 1커밋"
}
  • Response
    • Status: 201 Created
    • Content-Type: application/json
{
   result: "success",
   no: 1, // insertId (생성된 아이디)
   position: 3, // 카드 위치 순서
}

카드 수정

URL: /api/cards/:no
METHOD: PUT

  • Request
    • Content-Type: application/json
{
   listNo: 1,
   content: "1일 1회화"
}
  • Response
    • Status: 204 No Content

카드 포지션 한개 수정

  • position을 가장 큰 값으로 바꿔주는 API -> 따라서 조회시 최하단에 출력되게 된다.

URL: /api/cards/:no/position
METHOD: PATCH

  • Request
    • Content-Type: application/json
{
   listNo: 1
}
  • Response
    • Status: 204 No Content

카드 포지션 전체 수정

  • dragNo의 position을 dropNo의 position으로 바꿔준 뒤, 하위 카드들의 모든 position을 1씩 더하는 API -> 따라서 Drag된 카드가 Drop된 위치에 맞게 저장된다.

URL: /api/cards/:dragNo/:dropNo/position
METHOD: PATCH

  • Request
    • Content-Type: application/json
{
   listNo: 1
}
  • Response
    • Status: 204 No Content

카드 삭제

URL: /api/cards/:no
METHOD: DELETE

  • Response
    • Status: 204 No Content

🚫 에러 응답

404

(1) 존재하지 않는 URL에 접근했을 때
(2) 존재하지 않는 데이터에게 CRUD를 시도할 때 등

  • Status: 404 Not Found
  • Content-Type: application/json
{
   result: "error"
   msg: "존재하지 않는 리소스입니다."
}