express.js, sequelize.js를 이용한 간단한 API 앱
package.json
에 정의된 다음 명령어로 실행이 가능합니다.
npm test # test using Jest
npm run coverage # test and post the coverage report to codecove
npm run lint # lint using ESLint
npm run fixlint # fixes lint with --fix option
npm run dev # run the API in development mode
npm run prod # run the API in production mode
로컬에서 띄우기 위해 준비해야할 것은 다음과 같습니다.
- NodeJS >= 10.x.x
- Docker Image
- docker-compose.yml 파일
- .env 파일
도커 이미지 빌드
docker build . -t rest:latest
docker-compose.yml 파일은 docker-compose.example.yml 파일을 복사하세요.
cp docker-compose.example.yml docker-compose.yml
.env 파일은 .env.example 파일을 복사하세요.
cp .env.example .env
이제 준비가 되었습니다. 다음 명령어를 타이핑 하세요.
docker-compose up
복사한 docker-compose.yml 파일에는 Mysql DB가 link 되어 있습니다. docker-compose up
명령어는 mysql 컨테이너도 동시에 실행합니다.
src/
├─ api/
│ ├─ thing/
│ │ ├─ controller.js
│ │ ├─ index.js
│ │ ├─ index.test.js
│ │ ├─ model.js
│ │ └─ model.test.js
│ └─ index.js
├─ services/
│ ├─ db/
│ ├─ express/
│ ├─ response/
│ ├─ sequelize/
│ └─ your-service/
├─ app.js
├─ config.js
└─ index.js
기타 문의 사항은 issues에 남겨주세요.