게시글 목록 전체 조회
URL : /post [GET] → 추후 내림차순, 오름차순 구현 예정
//response: 성공
[
{
"title": "post20",
"explained": "explainedzz",
"created_at": "2022-04-03T15:00:00.000Z",
"userid": 1,
"nickname": "jihoon",
"url": "/photo/1649056395932-taobao.png"
},
{
"title": "post22",
"explained": "explainedzz",
"created_at": "2022-04-03T15:00:00.000Z",
"userid": 1,
"nickname": "jihoon",
"url": "/photo/1649056607251-taobao.png"
}
]
// response: 실패
{
"status":"fail"
}
특정 게시물 조회
URL:/post/:id [GET]
json 배열 0번째 → 게시글 정보
json 배열 1번째 ~끝까지 → 댓글 정보
[
{
"postid": 28,
"nickname": "jihoon",
"title": "zzzzz",
"explained": "explainedzz",
"created_at": "2022-04-03T15:00:00.000Z",
"photos": [
"/photo/1649057986371-taobao.png",
"/photo/1649057986374-KakaoTalk_20220304_160836536.jpg"
]
},
{
"postid": 28,
"userid": 2,
"created_at": "2022-04-06T15:00:00.000Z",
"comments": "undefined"
},
{
"postid": 28,
"userid": 2,
"created_at": "2022-04-06T15:00:00.000Z",
"comments": "this is comment"
}
]
//response: 실패
{
"status":"fail"
}
게시글 추가
사진 없는 게시글
URL: /post/ [POST]
사진 있는 게시글
URL: /post/photo [POST]
//request
{
"title":제목
"explained":설명추가
}
//response : 성공
{"status":"success","text":"글 등록이 완료되었습니다."}
//response: 실패
{"text": "ErrorCode:400, 잘못된 요청입니다."}
게시글 수정
사진 없는 게시글 수정
URL: /post/:id [PUT]
사진 있는 게시글 수정
URL: /post/photo/:id [PUT]
//request
{
"title":수정할 제목
"explained":수정할 설명
}
//response : 성공
{"status":"success","text":"글 수정이 완료되었습니다."}
//response
//글 작성자가 아닌경우
{"status":"fail", "text":"글 작성자만 수정이 가능합니다."}
게시글 삭제
URL: /post/:id [DELETE]
//response
//성공
{status:"success", text:"글 삭제를 성공했습니다."}
//실패
{status:"fail", text:"글 작성자만 삭제가 가능합니다."}