Giter Site home page Giter Site logo

little-web's Introduction

Little web

Node.js MySQL Docker Nginx

Quick Start

# 실행
docker-compose up

# 종료
docker-compose down

ERD

wanted-pre-onboarding-backend

클라우드 환경

My First Board (2)

구현 방법 및 이유

  • docker-compose로 배포 환경을 구성한 후 개발을 시작했습니다. 개발이 완료된 후 배포를 준비하면 환경적 차이 때문에 수정해야 하는 부분이 많이 생겨 처음부터 배포 환경을 구성했습니다.
  • JWT를 이용해 Refresh Token과 Access Token을 이용해 사용자 인증을 관리했습니다. Refresh Token을 사용함으로써 Token이 만료되기 전까지 매번 사용자가 로그인할 필요성이 사라지고, Access Token을 발급하기에도 편리합니다.
  • Joi를 활용해 request validator를 생성해 들어오는 요청 사항들을 검증했습니다.
  • MVC 구조를 사용해 구현을 하였고, controller 대신에 service를 생성하여 구현했습니다.

API 명세

기능 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: 게시글을 삭제할 수 없습니다.

little-web's People

Contributors

mackerel-10 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.