Blog 게시글 API 규격서

자유의여신·2022년 5월 30일
0

1. 전체 게시글 목록 조회 API

  • 제목, 작성자명, 작성 날짜를 조회하기
  • 작성 날짜 기준으로 내림차순 정렬하기

Request

  • Method: GET
  • URL: /posts

Response

  • HTTP Status Code: 200
  • Payload:
{ postId: number, 
 title : string,
 editDate: string,
 editor : string,
 (editorId : string),
 postPw : string,
 content: string}[]

2. 게시글 작성 API

  • 제목, 작성자명, 비밀번호, 작성 내용을 입력하기

Request

  • Method: POST
  • URL: /posts
  • Body:
{ postId: number, 
 title : string,
 editDate: string,
 editor : string,
 (editorId : string),
 postPw : string,
 content: string}[]

Response

  • HTTP Status Code: 201
  • Payload:
{ postId: number }

3.게시글 상세 조회 API

  • 제목, 작성자명, 작성 날짜, 작성 내용을 조회하기
    (검색 기능이 아닙니다. 간단한 게시글 조회만 구현해주세요.)

Request

  • Method: GET
  • URL: /posts/:postId

Response

  • HTTP Status Code: 200
  • Payload:
{ postId: number, 
  title : string,
  editDate: string,
  editor : string,
  content: string }

4. 게시글 수정 API

  • API를 호출할 때 입력된 비밀번호를 비교하여 동일할 때만 글이 수정되게 하기

Request

  • Method: PUT
  • URL: /posts/:postId
  • Body:
{ postPw : string, 
  title: string, 
  content: string }

Response

  • HTTP Status Code: 200
  • Payload:
{ message: string }

5. 게시글 삭제 API

  • API를 호출할 때 입력된 비밀번호를 비교하여 동일할 때만 글이 삭제되게 하기

Request

  • Method: DELETE
  • URL: /posts/:postId

Response

  • HTTP Status Code: 200
  • Payload:
{ message: string }

  1. 수정, 삭제 API의 request를 어떤 방식으로 사용하셨나요? (param, query, body)
  2. 어떤 상황에 어떤 방식의 request를 써야하나요?
  3. RESTful한 API를 설계했나요? 어떤 부분이 그런가요? 어떤 부분이 그렇지 않나요?
profile
나만의 색깔

0개의 댓글