[week6] 프로젝트 : Node.js 기반의 REST API 구현 (2) - 02/09

Kyulee·2026년 2월 9일

TIL 

목록 보기
28/80
post-thumbnail

API 설계

저번 시간 화면 별 주요 기능을 토대로 API를 설계 해볼 예정입니다.
👉🏻화면소개 및 주요 기능 확인하기

1. 회원 API

1. 회원가입

Method POST
URI /users/join
HTTP status code 성공 201
Request Body
{
  "email" : "사용자가 입력한 이메일",
  "password" : "사용자가 입력한 비밀번호"
}
Response Body x

2. 로그인

Method POST
URI /users/login
HTTP status code 성공 200
Request Body
{
  "email" : "사용자가 입력한 이메일",
  "password" : "사용자가 입력한 비밀번호"
}
Response Body JWT_TOKEN

3. 비밀번호 초기화 요청

Method POST
URI /users/reset
HTTP status code 성공 200
Request Body
{
  "email" : "사용자가 입력한 이메일"
}
Response Body x

4. 비밀번호 초기화 (=수정)

Method PUT
URI /users/reset
HTTP status code 성공 200
Request Body
{
  "email" : "사용자가 입력한 이메일",
  "password" : "사용자가 입력한 새로운 비밀번호"
}
Response Body x

도서 API

1. 전체 도서 조회

Method GET
URI /books
HTTP status code 성공 200
Request Body x
Response Body
[
  {
    "id": "도서 id",
    "title": "도서 제목",
    "summary": "요약 설명",
    "author": "도서 작가",
    "price": "가격",
    "likes": "좋아요 수",
    "pubDate": "출간일"
  },
  {
    "id": "도서 id",
    "title": "도서 제목",
    "summary": "요약 설명",
    "author": "도서 작가",
    "price": "가격",
    "likes": "좋아요 수",
    "pubDate": "출간일"
  }
]

2. 개별 도서 조회

Method GET
URI /books/{bookid}
HTTP status code 성공 200
Request Body x
Response Body
{
  "id": "도서 id",
  "title": "도서 제목",
  "category": "카테고리",
  "format": "포맷",
  "isbn": "isbn",
  "summary": "요약 설명",
  "description": "상세 설명",
  "author": "도서 작가",
  "pages": "쪽 수",
  "index": "목차",
  "price": "가격",
  "likes": "좋아요 수",
  "liked": true,
  "pubDate": "출간일"
}

3. 카테고리별 도서 목록 조회

Method GET
URI /books?category_id={category_id}&new={boolean}
HTTP status code 성공 200
Request Body x
Response Body
[
  {
    "id": "도서 id",
    "title": "도서 제목",
    "summary": "요약 설명",
    "author": "도서 작가",
    "price": "가격",
    "likes": "좋아요 수",
    "pubDate": "출간일"
  },
  {
    "id": "도서 id",
    "title": "도서 제목",
    "summary": "요약 설명",
    "author": "도서 작가",
    "price": "가격",
    "likes": "좋아요 수",
    "pubDate": "출간일"
  }
]

좋아요 API

1. 좋아요 추가

Method POST
URI /likes/{bookId}
HTTP status code 성공 200
Request Body x
Response Body x

2. 좋아요 취소

Method DELETE
URI /likes/{bookId}
HTTP status code 성공 200
Request Body x
Response Body x

장바구니 API

1. 장바구니 담기

Method POST
URI /cart
HTTP status code 성공 201
Request Body
{
  "bookId" : "도서 id",
  "count" : "수량"
}
Response Body x

2. 장바구니 조회

Method GET
URI /cart
HTTP status code 성공 200
Request Body x
Response Body
[
  {
    "cart_item_Id": "장바구니 도서 id",
    "bookId": "도서 id",
    "title": "도서 제목",
    "summary": "도서 요약",
    "count": "수량",
    "price": "가격"
  },
  {
    "cart_item_Id": "장바구니 도서 id",
    "bookId": "도서 id",
    "title": "도서 제목",
    "summary": "도서 요약",
    "count": "수량",
    "price": "가격"
  }
]

3. 장바구니 도서 삭제

Method DELETE
URI /cart/{bookid}
HTTP status code 성공 200
Request Body x
Response Body x

02/10 수정 및 추가

4. 장바구니에서 선택한 주문 예상 상품 목록 조회

Method GET
URI /cart
HTTP status code 성공 200
Request Body
{ cart_item_id,  cart_item_id, ...}
Response Body

  {
    "cart_item_Id": "장바구니 도서 id",
    "bookId": "도서 id",
    "title": "도서 제목",
    "summary": "도서 요약",
    "count": "수량",
    "price": "가격"
  },
  {
    "cart_item_Id": "장바구니 도서 id",
    "bookId": "도서 id",
    "title": "도서 제목",
    "summary": "도서 요약",
    "count": "수량",
    "price": "가격"
  }
]

주문 API

1. 주문하기

Method POST
URI /orders
HTTP status code 성공 200
Request Body
{
    items : [ {
         cart_item_Id : 장바구니 도서 Id,
         count : 수량
     }
      {
         cart_item_Id : 장바구니 도서 Id,
         count : 수량
     }
     ],
    delivery : {
        adress : “주소”,
        receiver : “이름”,
        contact : “010-xxxx-xxxx”
    }
    totalPrice : 총 금액
}
       
Response Body x

2. 주문 목록(내역) 조회

Method GET
URI /orders
HTTP status code 성공 200
Request Body x
Response Body
[
    {
    	  order_id : ‘주문 id’,
          created_at : ‘주문일자’,
          delivery : {
                  address : ‘주소’,
                  receiver : ‘이름’,
                  contact : ‘전화번호’
           }
           bookTitle: “대표 책 제목”,
           totalPrice : 결제 금액,
           totalCount : 총 수량
     }
]
        

3. 주문 상세 조회

Method GET
URI /orders/{order_id}
HTTP status code 성공 200
Request Body x
Response Body
[
    {
         bookId : 도서 Id,
         bookTitle : ‘도서 제목’,
         author : ‘작가명’,
         price : 가격,
         count : 수량
     }
    {
         bookId : 도서 Id,
         bookTitle : ‘도서 제목’,
         author : ‘작가명’,
         price : 가격,
         count : 수량
     }
    …..
]
        
profile
안녕하세요 매일의 배움을 기록으로 자산화하는 개발자 이규현입니다 😊

0개의 댓글