Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danielfsousa/express-rest-boilerplate
⌛️ Express starter for building RESTful APIs
https://github.com/danielfsousa/express-rest-boilerplate
api boilerplate docker es2021 express express-boilerplate hacktoberfest microservices mongodb mongoose nodejs rest rest-api starter
Last synced: 2 days ago
JSON representation
⌛️ Express starter for building RESTful APIs
- Host: GitHub
- URL: https://github.com/danielfsousa/express-rest-boilerplate
- Owner: danielfsousa
- License: mit
- Created: 2017-07-18T01:59:19.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-06-30T03:36:43.000Z (6 months ago)
- Last Synced: 2024-12-11T00:05:15.462Z (2 days ago)
- Topics: api, boilerplate, docker, es2021, express, express-boilerplate, hacktoberfest, microservices, mongodb, mongoose, nodejs, rest, rest-api, starter
- Language: JavaScript
- Homepage:
- Size: 1.98 MB
- Stars: 2,364
- Watchers: 55
- Forks: 624
- Open Issues: 40
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesomes - express rest
- awesome-boilerplate - Express Rest Boilerplate
- awesome-boilerplate - Github
- awesome-boilerplate - Github
README
# Express ES2017 REST API Boilerplate
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![npm version](https://badge.fury.io/js/express-rest-es2017-boilerplate.svg)](https://badge.fury.io/js/express-rest-es2017-boilerplate) [![Build Status](https://travis-ci.org/danielfsousa/express-rest-es2017-boilerplate.svg?branch=master)](https://travis-ci.org/danielfsousa/express-rest-es2017-boilerplate) [![Coverage Status](https://coveralls.io/repos/github/danielfsousa/express-rest-es2017-boilerplate/badge.svg?branch=master)](https://coveralls.io/github/danielfsousa/express-rest-es2017-boilerplate?branch=master)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](https://yarnpkg.com)
- Express + MongoDB ([Mongoose](http://mongoosejs.com/))
- Consistent coding styles with [editorconfig](http://editorconfig.org)
- [Docker](https://www.docker.com/) support
- Uses [helmet](https://github.com/helmetjs/helmet) to set some HTTP headers for security
- Load environment variables from .env files with [dotenv](https://github.com/rolodato/dotenv-safe)
- Request validation with [joi](https://github.com/hapijs/joi)
- Gzip compression with [compression](https://github.com/expressjs/compression)
- Linting with [eslint](http://eslint.org)
- Tests with [mocha](https://mochajs.org), [chai](http://chaijs.com) and [sinon](http://sinonjs.org)
- Code coverage with [istanbul](https://istanbul.js.org) and [coveralls](https://coveralls.io)
- Git hooks with [husky](https://github.com/typicode/husky)
- Logging with [morgan](https://github.com/expressjs/morgan)
- Authentication and Authorization with [passport](http://passportjs.org)
- API documentation generation with [apidoc](http://apidocjs.com)
- Continuous integration support with [travisCI](https://travis-ci.org)
- Monitoring with [pm2](https://github.com/Unitech/pm2)## Requirements
- [Node v7.6+](https://nodejs.org/en/download/current/) or [Docker](https://www.docker.com/)
- [Yarn](https://yarnpkg.com/en/docs/install)## Getting Started
#### Clone the repo and make it yours:
```bash
git clone --depth 1 https://github.com/danielfsousa/express-rest-es2017-boilerplate
cd express-rest-es2017-boilerplate
rm -rf .git
```#### Install dependencies:
```bash
yarn
```#### Set environment variables:
```bash
cp .env.example .env
```## Running Locally
```bash
yarn dev
```## Running in Production
```bash
yarn start
```## Lint
```bash
# lint code with ESLint
yarn lint# try to fix ESLint errors
yarn lint:fix# lint and watch for changes
yarn lint:watch
```## Test
```bash
# 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
```bash
# run lint and tests
yarn validate
```## Logs
```bash
# show logs in production
pm2 logs
```## Documentation
```bash
# generate and open api documentation
yarn docs
```## Docker
```bash
# run container locally
yarn docker:dev# run container in production
yarn docker:prod# run tests
yarn docker:test
```## Deploy
Set your server ip:
```bash
DEPLOY_SERVER=127.0.0.1
```Replace my Docker username with yours:
```bash
nano deploy.sh
```Run deploy script:
```bash
yarn deploy
```## Tutorials
- [Create API Documentation Using Squarespace](https://selfaware.blog/home/2018/6/23/api-documentation)## Inspirations
- [KunalKapadia/express-mongoose-es6-rest-api](https://github.com/KunalKapadia/express-mongoose-es6-rest-api)
- [diegohaz/rest](https://github.com/diegohaz/rest)## License
[MIT License](README.md) - [Daniel Sousa](https://github.com/danielfsousa)