# 실행
docker-compose up
# 종료
docker-compose down
- docker-compose로 배포 환경을 구성한 후 개발을 시작했습니다. 개발이 완료된 후 배포를 준비하면 환경적 차이 때문에 수정해야 하는 부분이 많이 생겨 처음부터 배포 환경을 구성했습니다.
- JWT를 이용해 Refresh Token과 Access Token을 이용해 사용자 인증을 관리했습니다. Refresh Token을 사용함으로써 Token이 만료되기 전까지 매번 사용자가 로그인할 필요성이 사라지고, Access Token을 발급하기에도 편리합니다.
- Joi를 활용해 request validator를 생성해 들어오는 요청 사항들을 검증했습니다.
- MVC 구조를 사용해 구현을 하였고, controller 대신에 service를 생성하여 구현했습니다.
기능 | HTTP Method | EndPoint | Request | Response | |
---|---|---|---|---|---|
Auth | 회원가입 | POST | /api/v1/auth/users | Request Body content: x-www-form-urlencoded { "email": "[email protected]", "password": "qwerty1234" } |
- 200: 회원가입 했습니다. - 400: 사용자가 있습니다. |
로그인 | POST | /api/v1/auth/signin | Request Body content: x-www-form-urlencoded { "email": "[email protected]", "password": "qwerty1234" } |
- 200: 로그인 했습니다. Header: X-Refresh-Token(Bearer, Refresh Token), Authorization(Bearer, Access Token) - 400: 잘못된 비밀번호입니다. - 404: 사용자가 없습니다. |
|
Posts | 게시글 생성 | POST | /api/v1/posts | Request Header Authorization(Bearer, Access Token) Request Body content: x-www-form-urlencoded { "title": "hello", "content": "world" } |
- 201: 게시글이 작성됐습니다. |
게시글 목록 조회 | GET | /api/v1/posts 요청 예시: /api/v1/posts?page=1&perPage=10 |
Query page: Number perPage: Number |
- 200: 게시글 목록을 불러왔습니다., { "message": "게시글 목록을 불러왔습니다.", "data": { "postList": [ { "id": 1, "author_id": 1, "title": "hello", "content": "world", "created_at": "2023-08-06T13:40:40.000Z", "updated_at": "2023-08-06T13:40:40.000Z" } ] }, } - 404: 게시글이 없습니다. |
|
특정 게시글 조회 | GET | /api/v1/posts/:id | Param id: Number |
- 200: 게시글을 불러왔습니다. { "message": "게시글을 불러왔습니다.", "data": { "post": { "id": 1, "author_id": 1, "title": "hello", "content": "world", "created_at": "2023-08-06T13:40:40.000Z", "updated_at": "2023-08-06T13:40:40.000Z" } }, } - 404: 게시글이 없습니다. |
|
특정 게시글 수정 | PUT | /api/v1/posts/:id | Request Header Authorization(Bearer, Access Token) Param id: Number Request Body content: x-www-form-urlencoded { "title": "hello", "content": "world" } |
- 200: 게시글을 수정했습니다. - 404: 게시글을 수정할 수 없습니다. |
|
특정 게시글 삭제 | DELETE | /api/v1/posts/:id | Request Header Authorization(Bearer, Access Token) Param id: Number |
- 200: 게시글을 삭제했습니다. - 404: 게시글을 삭제할 수 없습니다. |