Code Monkey home page Code Monkey logo

nodejs-api-boilerplate's Introduction

Prerequisite

  1. NodeJS
  2. Node Package Management (yarn or npm)
  3. Docker

Installation

  1. Clone the project git clone [email protected]:vukhanhtruong/nodejs-api-boilerplate.git.
  2. Install dependencies yarn install or npm i
  3. Copy .env.example to .env file.

Running Docker

docker-compose up -d.


Raven Log

Create account at Sentry, then put your url to .env file at variable SENTRY_DSN.


Api Doc

Api doc his hosted on surge. For change the url and have your own docs just modify your link in the .env file. Running the following command to publish your documentation.

# Generate document
yarn doc
# Deploy document to surge.sh
yarn doc:deploy

# or
npm run doc
npm run doc:deploy

Pre-Commit Hook

Using husky for linting your code before commit & running unit test before push.


Scripts

DEV

yarn dev

# or

npm run dev

DEBUG

Debug with VSCode. See VSCode Auto-Attach

yarn debug

# or

npm run debug

TEST

yarn test

# or

npm run test

NOTE: If you have the issue with ENOSPC, run the below command to avoid:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Test Watch

yarn test:watch

COVERAGE

# run jest coverage
yarn test:cover

# show html report
yarn test:cover:open

# or

npm run test:cover

npm run test:cover:open

JSDOC

# generate documentation
yarn doc

# Publish documentation to surge.sh
yarn doc:deploy

#or

npm run doc

npm run doc:deploy

Deployment

Heroku Configuration

Generate heroku token. Then add this token to Gitlab CI Variables as HEROKU_TOKEN

heroku auth:token

Gitlab CI & CD

Code will automatically test & deploy to Heroku after merging into development branch.

To test gitlabCI on locally, run the following command

# to run test service
gitlab-runner exec docker test

# to run deployment service
gitlab-runner exec docker development --docker-privileged

References


nodejs-api-boilerplate's People

Contributors

ces-truongvu avatar

Watchers

Mauro avatar James Cloos 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.