API 설계
Api Response Format
header:{ statusCode: 200 }, body:{ -> 위에 적은 response 형태 "postId": 1, "content": "ahpuh", "score": 100 }
Date Format
- 날짜 & 시간: yyyy-MM-dd HH:mm:ss // 생성날짜, 수정 시간 .. server time 그대로 적용해서 그런거임
- selectedDate : yyyy-MM-dd // post 쓸떄 날짜 지정했을때 다음 형식으로 request하고, response도 string도
GET, DELETE => header에 데이터 포함
POST, PUT => body에 데이터 포함
Status Code
- get, put → 200 ok
- post → 201 created
Location: /posts/{postId} - 리스소가 생성된 위치 (헤더)
- delete → 200 ok (응답 바디 있을 경우) vs 204 no-content (응답 바디 없을 경우)
참고 글
Validation
- user
- maxlength = 254
- username
- maxLength = 20
- password
- maxLength = 20 → (암화화 되어 들어간 password 길이 == 60자)
- 숫자, 영문자(대소문자) 포함 8 ~ 20
- post
- content
- maxLength = 500
- score
- min = 0, max = 100
- category
- name
- maxLength = 30