express-rest-es2017-boilerplate

⌛️ Express boilerplate for building RESTful APIs

Github星跟踪图

Express ES2017 REST API Boilerplate

PRs Welcome npm version Build Status Coverage Status

Boilerplate/Generator/Starter Project for building RESTful APIs and microservices using Node.js, Express and MongoDB

Features

  • No transpilers, just vanilla javascript
  • ES2017 latest features like Async/Await
  • CORS enabled
  • Uses yarn
  • Express + MongoDB (Mongoose)
  • Consistent coding styles with editorconfig
  • Docker support
  • Uses helmet to set some HTTP headers for security
  • Load environment variables from .env files with dotenv
  • Request validation with joi
  • Gzip compression with compression
  • Linting with eslint
  • Tests with mocha, chai and sinon
  • Code coverage with istanbul and coveralls
  • Git hooks with husky
  • Logging with morgan
  • Authentication and Authorization with passport
  • API documentation generation with apidoc
  • Continuous integration support with travisCI
  • Monitoring with pm2

Requirements

Getting Started

Clone the repo and make it yours:

git clone --depth 1 https://github.com/danielfsousa/express-rest-es2017-boilerplate
cd express-rest-es2017-boilerplate
rm -rf .git

Install dependencies:

yarn

Set environment variables:

cp .env.example .env

Running Locally

yarn dev

Running in Production

yarn start

Lint

# lint code with ESLint
yarn lint

# try to fix ESLint errors
yarn lint:fix

# lint and watch for changes
yarn lint:watch

Test

# run all tests with Mocha
yarn test

# run unit tests
yarn test:unit

# run integration tests
yarn test:integration

# run all tests and watch for changes
yarn test:watch

# open nyc test coverage reports
yarn coverage

Validate

# run lint and tests
yarn validate

Logs

# show logs in production
pm2 logs

Documentation

# generate and open api documentation
yarn docs

Docker

# run container locally
yarn docker:dev

# run container in production
yarn docker:prod

# run tests
yarn docker:test

Deploy

Set your server ip:

DEPLOY_SERVER=127.0.0.1

Replace my Docker username with yours:

nano deploy.sh

Run deploy script:

yarn deploy

Tutorials

Inspirations

License

MIT License - Daniel Sousa

主要指标

概览
名称与所有者danielfsousa/express-rest-boilerplate
主编程语言JavaScript
编程语言Shell (语言数: 5)
平台
许可证MIT License
所有者活动
创建于2017-07-18 01:59:19
推送于2024-06-30 03:36:43
最后一次提交
发布数16
最新版本名称1.2.11 (发布于 2024-06-29 18:45:12)
第一版名称v1.0.0 (发布于 2017-07-23 03:12:23)
用户参与
星数2.4k
关注者数54
派生数619
提交数244
已启用问题?
问题数62
打开的问题数13
拉请求数179
打开的拉请求数26
关闭的拉请求数426
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?