{"id":13475197,"url":"https://github.com/kunalkapadia/express-mongoose-es6-rest-api","last_synced_at":"2025-04-13T16:10:37.468Z","repository":{"id":49879102,"uuid":"50340470","full_name":"kunalkapadia/express-mongoose-es6-rest-api","owner":"kunalkapadia","description":":collision: A boilerplate application for building RESTful APIs Microservice in Node.js using express and mongoose in ES6 with code coverage and JsonWebToken Authentication","archived":false,"fork":false,"pushed_at":"2020-07-15T23:39:14.000Z","size":304,"stargazers_count":2929,"open_issues_count":67,"forks_count":690,"subscribers_count":111,"default_branch":"develop","last_synced_at":"2025-04-06T13:08:17.785Z","etag":null,"topics":["authentication","babel","bluebird","boilerplate","coverage","dotenv","es6","eslint","express","jsonwebtoken","mocha","mongodb","mongoose","node","yarn"],"latest_commit_sha":null,"homepage":"http://kunalkapadia.github.io/express-mongoose-es6-rest-api/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kunalkapadia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-25T09:33:29.000Z","updated_at":"2025-03-24T02:03:03.000Z","dependencies_parsed_at":"2022-08-12T20:50:33.860Z","dependency_job_id":null,"html_url":"https://github.com/kunalkapadia/express-mongoose-es6-rest-api","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kunalkapadia%2Fexpress-mongoose-es6-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kunalkapadia%2Fexpress-mongoose-es6-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kunalkapadia%2Fexpress-mongoose-es6-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kunalkapadia%2Fexpress-mongoose-es6-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kunalkapadia","download_url":"https://codeload.github.com/kunalkapadia/express-mongoose-es6-rest-api/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248741201,"owners_count":21154255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","babel","bluebird","boilerplate","coverage","dotenv","es6","eslint","express","jsonwebtoken","mocha","mongodb","mongoose","node","yarn"],"created_at":"2024-07-31T16:01:18.180Z","updated_at":"2025-04-13T16:10:37.447Z","avatar_url":"https://github.com/kunalkapadia.png","language":"JavaScript","funding_links":["https://www.paypal.me/KunalKapadia"],"categories":["JavaScript"],"sub_categories":[],"readme":"# Express \u0026 mongoose REST API Boilerplate in ES6 with Code Coverage [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)\n\n[![Build Status](https://img.shields.io/travis/kunalkapadia/express-mongoose-es6-rest-api/master.svg?style=flat-square)](https://travis-ci.org/kunalkapadia/express-mongoose-es6-rest-api)\n[![Coverage Status](https://img.shields.io/coveralls/kunalkapadia/express-mongoose-es6-rest-api/master.svg?style=flat-square)](https://coveralls.io/github/kunalkapadia/express-mongoose-es6-rest-api?branch=master)\n[![Code Climate](https://img.shields.io/codeclimate/github/kunalkapadia/express-mongoose-es6-rest-api.svg?style=flat-square)](https://codeclimate.com/github/kunalkapadia/express-mongoose-es6-rest-api)\n[![bitHound Overall Score](https://www.bithound.io/github/kunalkapadia/express-es6-rest-api-starter/badges/score.svg)](https://www.bithound.io/github/kunalkapadia/express-es6-rest-api-starter)\n[![bitHound Dependencies](https://www.bithound.io/github/kunalkapadia/express-mongoose-es6-rest-api/badges/dependencies.svg)](https://www.bithound.io/github/kunalkapadia/express-mongoose-es6-rest-api/master/dependencies/npm)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)\n[![MIT License](https://img.shields.io/npm/l/stack-overflow-copy-paste.svg?style=flat-square)](http://opensource.org/licenses/MIT)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n[![Support via Paypal](https://img.shields.io/badge/support-paypal-yellowgreen.svg?style=flat-square)](https://www.paypal.me/KunalKapadia)\n\n# [![Express ES6 REST API Starter](https://cloud.githubusercontent.com/assets/4172932/12660610/90f5b856-c63a-11e5-878e-c9f0bbf33090.jpg)](https://github.com/kunalkapadia/express-mongoose-es6-rest-api)\n\n## Sponsor\nYou can support the project by checking out our sponsor page. It takes only one click:\n\n\u003ca href=\"https://tracking.gitads.io/?repo=express-mongoose-es6-rest-api\" target=\"_blank\"\u003e \u003cimg src=\"https://images.gitads.io/express-mongoose-es6-rest-api\" alt=\"Some great stuff\" style=\"height: auto !important;width: auto !important;\"/\u003e \u003c/a\u003e\n\n## Overview\n\nThis is a boilerplate application for building REST APIs in Node.js using ES6 and Express with Code Coverage and JWT Authentication. Helps you stay productive by following best practices. Follows [Airbnb's Javascript style guide](https://github.com/airbnb/javascript).\n\nHeavily inspired from [Egghead.io - How to Write an Open Source JavaScript Library](https://egghead.io/courses/how-to-write-an-open-source-javascript-library).\n\n### Features\n\n| Feature                                | Summary                                                                                                                                                                                                                                                     |\n|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ES6 via Babel                  \t \t | ES6 support using [Babel](https://babeljs.io/).  |\n| Authentication via JsonWebToken                  \t \t | Supports authentication using [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken).  |\n| Code Linting               \t\t\t | JavaScript code linting is done using [ESLint](http://eslint.org) - a pluggable linter tool for identifying and reporting on patterns in JavaScript. Uses ESLint with [eslint-config-airbnb](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb), which tries to follow the Airbnb JavaScript style guide.                                                                                                |\n| Auto server restart                  \t | Restart the server using [nodemon](https://github.com/remy/nodemon) in real-time anytime an edit is made, with babel compilation and eslint.                                                                                                                                                                            |\n| ES6 Code Coverage via [istanbul](https://www.npmjs.com/package/istanbul)                  | Supports code coverage of ES6 code using istanbul and mocha. Code coverage reports are saved in `coverage/` directory post `yarn test` execution. Open `coverage/lcov-report/index.html` to view coverage report. `yarn test` also displays code coverage summary on console. Code coverage can also be enforced overall and per file as well, configured via .istanbul.yml                                                                                                                                                                            |\n| Debugging via [debug](https://www.npmjs.com/package/debug)           | Instead of inserting and deleting console.log you can replace it with the debug function and just leave it there. You can then selectively debug portions of your code by setting DEBUG env variable. If DEBUG env variable is not set, nothing is displayed to the console.                       |\n| Promisified Code via [bluebird](https://github.com/petkaantonov/bluebird)           | We love promise, don't we ? All our code is promisified and even so our tests via [supertest-as-promised](https://www.npmjs.com/package/supertest-as-promised).                       |\n| API parameter validation via [express-validation](https://www.npmjs.com/package/express-validation)           | Validate body, params, query, headers and cookies of a request (via middleware) and return a response with errors; if any of the configured validation rules fail. You won't anymore need to make your route handler dirty with such validations. |\n| Pre-commit hooks           | Runs lint and tests before any commit is made locally, making sure that only tested and quality code is committed\n| Secure app via [helmet](https://github.com/helmetjs/helmet)           | Helmet helps secure Express apps by setting various HTTP headers. |\n| Uses [yarn](https://yarnpkg.com) over npm            | Uses new released yarn package manager by facebook. You can read more about it [here](https://code.facebook.com/posts/1840075619545360) |\n\n- CORS support via [cors](https://github.com/expressjs/cors)\n- Uses [http-status](https://www.npmjs.com/package/http-status) to set http status code. It is recommended to use `httpStatus.INTERNAL_SERVER_ERROR` instead of directly using `500` when setting status code.\n- Has `.editorconfig` which helps developers define and maintain consistent coding styles between different editors and IDEs.\n\n## Getting Started\n\nClone the repo:\n```sh\ngit clone git@github.com:kunalkapadia/express-mongoose-es6-rest-api.git\ncd express-mongoose-es6-rest-api\n```\n\nInstall yarn:\n```js\nnpm install -g yarn\n```\n\nInstall dependencies:\n```sh\nyarn\n```\n\nSet environment (vars):\n```sh\ncp .env.example .env\n```\n\nStart server:\n```sh\n# Start server\nyarn start\n\n# Selectively set DEBUG env var to get logs\nDEBUG=express-mongoose-es6-rest-api:* yarn start\n```\nRefer [debug](https://www.npmjs.com/package/debug) to know how to selectively turn on logs.\n\n\nTests:\n```sh\n# Run tests written in ES6 \nyarn test\n\n# Run test along with code coverage\nyarn test:coverage\n\n# Run tests on file change\nyarn test:watch\n\n# Run tests enforcing code coverage (configured via .istanbul.yml)\nyarn test:check-coverage\n```\n\nLint:\n```sh\n# Lint code with ESLint\nyarn lint\n\n# Run lint on any file change\nyarn lint:watch\n```\n\nOther gulp tasks:\n```sh\n# Wipe out dist and coverage directory\ngulp clean\n\n# Default task: Wipes out dist and coverage directory. Compiles using babel.\ngulp\n```\n\n##### Deployment\n\n```sh\n# compile to ES5\n1. yarn build\n\n# upload dist/ to your server\n2. scp -rp dist/ user@dest:/path\n\n# install production dependencies only\n3. yarn --production\n\n# Use any process manager to start your services\n4. pm2 start dist/index.js\n```\n\nIn production you need to make sure your server is always up so you should ideally use any of the process manager recommended [here](http://expressjs.com/en/advanced/pm.html).\nWe recommend [pm2](http://pm2.keymetrics.io/) as it has several useful features like it can be configured to auto-start your services if system is rebooted.\n\n## Logging\n\nUniversal logging library [winston](https://www.npmjs.com/package/winston) is used for logging. It has support for multiple transports.  A transport is essentially a storage device for your logs. Each instance of a winston logger can have multiple transports configured at different levels. For example, one may want error logs to be stored in a persistent remote location (like a database), but all logs output to the console or a local file. We just log to the console for simplicity, you can configure more transports as per your requirement.\n\n#### API logging\nLogs detailed info about each api request to console during development.\n![Detailed API logging](https://cloud.githubusercontent.com/assets/4172932/12563354/f0a4b558-c3cf-11e5-9d8c-66f7ca323eac.JPG)\n\n#### Error logging\nLogs stacktrace of error to console along with other details. You should ideally store all error messages persistently.\n![Error logging](https://cloud.githubusercontent.com/assets/4172932/12563361/fb9ef108-c3cf-11e5-9a58-3c5c4936ae3e.JPG)\n\n## Code Coverage\nGet code coverage summary on executing `yarn test`\n![Code Coverage Text Summary](https://cloud.githubusercontent.com/assets/4172932/12827832/a0531e70-cba7-11e5-9b7c-9e7f833d8f9f.JPG)\n\n`yarn test` also generates HTML code coverage report in `coverage/` directory. Open `lcov-report/index.html` to view it.\n![Code coverage HTML report](https://cloud.githubusercontent.com/assets/4172932/12625331/571a48fe-c559-11e5-8aa0-f9aacfb8c1cb.jpg)\n\n## Docker\n\n#### Using Docker Compose for Development\n```sh\n# service restarts on file change\nbash bin/development.sh\n```\n\n#### Building and running without Docker Compose\n```bash\n# To use this option you need to make sure mongodb is listening on port 27017\n\n# Build docker \ndocker build -t express-mongoose-es6-rest-api .\n\n# Run docker\ndocker run -p 4040:4040 express-mongoose-es6-rest-api\n```\n\n\n## A Boilerplate-only Option\n\nIf you would prefer not to use any of our tooling, delete the following files from the project: `package.json`, `gulpfile.babel.js`, `.eslintrc` and `.travis.yml`. You can now safely use the boilerplate with an alternative build-system or no build-system at all if you choose.\n\n## Docs and Recipes\n\n* [Gulp recipes](https://github.com/gulpjs/gulp/tree/master/docs/recipes) - the official Gulp recipes directory includes a comprehensive list of guides for different workflows you can add to your project.\n\n## Contributing\n\nContributions, questions and comments are all welcome and encouraged. For code contributions submit a pull request with unit test.\n\n## License\nThis project is licensed under the [MIT License](https://github.com/kunalkapadia/express-mongoose-es6-rest-api/blob/master/LICENSE)\n\n## Support Development\nIf this project saved your valuable time in getting your service up, and you feel like buying me coffee, you can donate either at my BTC address: `1LkW5UoERR1jjJsChMheKuo6vn95x2mzWg` or at [![Support via Paypal](https://img.shields.io/badge/support-paypal-yellowgreen.svg?style=flat-square)](https://www.paypal.me/KunalKapadia)\n\nYour support is greatly appreciated.\n\n## Meta\n\nKunal Kapadia – [@kunalkapadia12](https://twitter.com/kunalkapadia12) – kunalkapadia12@gmail.com\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkunalkapadia%2Fexpress-mongoose-es6-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkunalkapadia%2Fexpress-mongoose-es6-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkunalkapadia%2Fexpress-mongoose-es6-rest-api/lists"}