{"id":13989749,"url":"https://github.com/EQuimper/nodejs-api-boilerplate","last_synced_at":"2025-07-22T11:31:36.994Z","repository":{"id":20177172,"uuid":"89078537","full_name":"EQuimper/nodejs-api-boilerplate","owner":"EQuimper","description":"A boilerplate for kickstart your nodejs api project with JWT Auth and some new Techs :)","archived":false,"fork":false,"pushed_at":"2023-01-23T19:27:20.000Z","size":2064,"stargazers_count":463,"open_issues_count":90,"forks_count":122,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-07-15T06:44:24.136Z","etag":null,"topics":["boilerplate","docker","docker-compose","es6","es7","eslint","express","javascript","joy","lint-staged","mongodb","mongoose","node-js","nodejs-api-boilerplate","nodejs-boilerplate","nps","prettier","raven","raven-log"],"latest_commit_sha":null,"homepage":"","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/EQuimper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-22T15:10:30.000Z","updated_at":"2025-05-23T21:03:29.000Z","dependencies_parsed_at":"2023-02-13T02:31:28.774Z","dependency_job_id":null,"html_url":"https://github.com/EQuimper/nodejs-api-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EQuimper/nodejs-api-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EQuimper%2Fnodejs-api-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EQuimper%2Fnodejs-api-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EQuimper%2Fnodejs-api-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EQuimper%2Fnodejs-api-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EQuimper","download_url":"https://codeload.github.com/EQuimper/nodejs-api-boilerplate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EQuimper%2Fnodejs-api-boilerplate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266483694,"owners_count":23936397,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["boilerplate","docker","docker-compose","es6","es7","eslint","express","javascript","joy","lint-staged","mongodb","mongoose","node-js","nodejs-api-boilerplate","nodejs-boilerplate","nps","prettier","raven","raven-log"],"created_at":"2024-08-09T13:02:01.821Z","updated_at":"2025-07-22T11:31:36.216Z","avatar_url":"https://github.com/EQuimper.png","language":"JavaScript","readme":"[![forthebadge](http://forthebadge.com/images/badges/60-percent-of-the-time-works-every-time.svg)](http://forthebadge.com)\n[![forthebadge](http://forthebadge.com/images/badges/as-seen-on-tv.svg)](http://forthebadge.com)\n[![forthebadge](http://forthebadge.com/images/badges/fuck-it-ship-it.svg)](http://forthebadge.com)\n\n---\n\n[![Code Climate](https://img.shields.io/codeclimate/github/EQuimper/nodejs-api-boilerplate.svg?style=flat-square)](https://codeclimate.com/github/EQuimper/nodejs-api-boilerplate)\n[![Coverage Status](https://img.shields.io/coveralls/EQuimper/nodejs-api-boilerplate/master.svg?style=flat-square)](https://coveralls.io/github/EQuimper/nodejs-api-boilerplate?branch=master)\n[![Build Status](https://img.shields.io/travis/EQuimper/nodejs-api-boilerplate/master.svg?style=flat-square)](https://travis-ci.org/EQuimper/nodejs-api-boilerplate)\n[![CircleCI](https://circleci.com/gh/EQuimper/nodejs-api-boilerplate.svg?\u0026style=shield)](https://circleci.com/gh/EQuimper/nodejs-api-boilerplate)\n[![Greenkeeper badge](https://badges.greenkeeper.io/EQuimper/nodejs-api-boilerplate.svg)](https://greenkeeper.io/)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\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[![Dependency Status](https://dependencyci.com/github/EQuimper/nodejs-api-boilerplate/badge)](https://dependencyci.com/github/EQuimper/nodejs-api-boilerplate)\n[![dependencies Status](https://david-dm.org/equimper/nodejs-api-boilerplate/status.svg?style=flat-square)](https://david-dm.org/equimper/nodejs-api-boilerplate)\n[![devDependencies Status](https://david-dm.org/equimper/nodejs-api-boilerplate/dev-status.svg?style=flat-square)](https://david-dm.org/equimper/nodejs-api-boilerplate?type=dev)\n[![nps](https://img.shields.io/badge/scripts%20run%20with-nps-blue.svg?style=flat-square)](https://github.com/kentcdodds/nps)\n[![code style equimper](https://img.shields.io/badge/code%20style-equimper-blue.svg?style=flat-square)](https://github.com/EQuimper/eslint-config-equimper)\n[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors)\n\n# NodeJS-API-Boilerplate\n\n[![forthebadge](http://forthebadge.com/images/badges/built-by-developers.svg)](http://forthebadge.com)\n[![forthebadge](http://forthebadge.com/images/badges/powered-by-water.svg)](http://forthebadge.com)\n[![forthebadge](http://forthebadge.com/images/badges/powered-by-netflix.svg)](http://forthebadge.com)\n[![forthebadge](http://forthebadge.com/images/badges/mom-made-pizza-rolls.svg)](http://forthebadge.com)\n[![forthebadge](http://forthebadge.com/images/badges/you-didnt-ask-for-this.svg)](http://forthebadge.com)\n[![forthebadge](http://forthebadge.com/images/badges/winter-is-coming.svg)](http://forthebadge.com)\n\n# Always in progress 👷‍\n\n# Get Started\n\n- [Installation](https://github.com/EQuimper/nodejs-api-boilerplate#installation)\n- [Install Mongodb](https://github.com/EQuimper/nodejs-api-boilerplate#install-mongodb)\n- [Raven Log](https://github.com/EQuimper/nodejs-api-boilerplate#raven-log)\n- [Body Whitelist](https://github.com/EQuimper/nodejs-api-boilerplate#body-whitelist)\n- [Api Doc](https://github.com/EQuimper/nodejs-api-boilerplate#api-doc)\n- [Pre-Commit Hook](https://github.com/EQuimper/nodejs-api-boilerplate#pre-commit-hook)\n- [Scripts](https://github.com/EQuimper/nodejs-api-boilerplate#scripts)\n- [Dev-Debug](https://github.com/EQuimper/nodejs-api-boilerplate#dev-debug)\n- [Why toJSON() on methods model](https://github.com/EQuimper/nodejs-api-boilerplate#why-tojson-on-methods-model-)\n- [For validation on request](https://github.com/EQuimper/nodejs-api-boilerplate#for-validation-on-request)\n- [Seeds](https://github.com/EQuimper/nodejs-api-boilerplate#seeds)\n- [Docker](https://github.com/EQuimper/nodejs-api-boilerplate#docker)\n- [Techs](https://github.com/EQuimper/nodejs-api-boilerplate#techs)\n- [Todo](https://github.com/EQuimper/nodejs-api-boilerplate#todo)\n\n## Build\n\nThis Boilerplate use webpack 3 to compile code.\n\n## Installation\n\n1. Clone the project `git clone https://github.com/EQuimper/nodejs-api-boilerplate.git`.\n2. Install dependencies `yarn install` or `npm i`\n3. Create a `.env` file in the root like the `.env.example` file.\n4. For dev you need to have mongodb db locally. [How to?](https://github.com/EQuimper/nodejs-api-boilerplate#install-mongodb)\n\n---\n\n## Install Mongodb\n\nWith Homebrew you can just run `brew install mongodb` and after `brew services start mongodb`.\n\n---\n\n## Raven Log\n\nFor get raven log create account here: [Sentry](https://sentry.io/)\n\n---\n\n## Body Whitelist\n\nFor security have add a whitelist function for your `req.body` coming from the front end. You can take a look of it in the `contants.js` file.\n\n```js\nconst WHITELIST = {\n  posts: {\n    create: ['title', 'text'],\n    update: ['title', 'text'],\n  },\n  users: {\n    create: ['email', 'username', 'password'],\n  },\n};\n```\n\n---\n\n## Api Doc\n\nApi doc his hosted on surge. [Link](http://equimper-nodejs-api-boilerplate.surge.sh/). For change the url and have your own docs just add you link in the `.env` file.\n\n---\n\n## Pre-Commit Hook\n\nI've add `pre-commit` and `lint-staged` for lint your code before commit. That can maybe take time :bowtie:\n\n---\n\n## Scripts\n\n### DEV\n\n```\nyarn dev\n```\n\nor\n\n```\nnpm run dev\n```\n\n**PS** That can crash if this is the first time but don't worry give it 2 sec the scripts gonna work. He just need to created a dist folder :) This way you have only one command to run.\n\n### DEV-DEBUG\n\n```\nyarn dev:debug\n```\n\nor\n\n```\nnpm run dev:debug\n```\n\n---\n\n## Why toJSON on methods model ?\n\n`toJSON()` help us to get only the data we want when we push the info to the client. So now we just need to put the user object in the `res.json(user)` and we received only what we want. Why `toAuthJSON()` ? Cause if we populated the post we get the `toJSON()` so the `toAuthJSON()` is the on to call on signup and login for get the token and _id.\n\n```js\ntoAuthJSON() {\n  return {\n    _id: this._id,\n    token: `JWT ${this.createToken()}`,\n  };\n},\n\ntoJSON() {\n  return {\n    _id: this._id,\n    username: this.username,\n  };\n},\n```\n\n---\n\n## For Validation on Request\n\nI'm using Joi in this boilerplate, that make the validation really easy.\n\n```js\nexport const validation = {\n  create: {\n    body: {\n      email: Joi.string().email().required(),\n      password: Joi.string().regex(/^[a-zA-Z0-9]{3,30}$/).required(),\n      username: Joi.string().min(3).max(20).required(),\n    },\n  },\n};\n\nroutes.post(\n  '/signup',\n  validate(UserController.validation.create),\n  UserController.create,\n);\n```\n\n## Seeds\n\nFor seed just run one of this following comand. This is helpful in dev for making fake user.\n\n**This is only available in dev environment**\n\n*You can change the number of seed by changing the number in each script inside `/scripts/seeds`*\n\n- Seeds 10 user `yarn db:seeds-user`\n- Clear user collection `yarn db:seeds-clear-user`\n- Clear all collection `yarn db:seeds-clear`\n\n---\n\nMonitoring Server on `http://localhost:3000/status`\n\n---\n\n\n## Docker\n\n```\nbash scripts/development.sh\n```\n\n---\n\n## Techs\n\n- [Helmet](https://github.com/helmetjs/helmet)\n- [Cors](https://github.com/expressjs/cors)\n- [Body-Parser](https://github.com/expressjs/body-parser)\n- [Morgan](https://github.com/expressjs/morgan)\n- [PassportJS](https://github.com/jaredhanson/passport)\n- [Passport-Local](https://github.com/jaredhanson/passport-local)\n- [Passport-JWT](https://github.com/themikenicholson/passport-jwt)\n- [Raven](https://github.com/getsentry/raven-node)\n- [Joi](https://github.com/hapijs/joi)\n- [Http-Status](https://github.com/adaltas/node-http-status)\n- [Lint-Staged](https://github.com/okonet/lint-staged)\n- [Husky](https://github.com/typicode/husky)\n- [Prettier](https://github.com/prettier/prettier)\n- [Eslint Config EQuimper](https://github.com/EQuimper/eslint-config-equimper)\n- [Eslint Config Prettier](https://github.com/prettier/eslint-config-prettier)\n- [CodeClimate](https://codeclimate.com/)\n- [Coveralls](https://github.com/integrations/coveralls)\n- [Travis Ci](https://travis-ci.org/)\n- [Circle Ci](https://circleci.com/)\n- [Greenkeeper](https://greenkeeper.io/)\n- [Istanbul](https://github.com/gotwarlost/istanbul)\n- [Mocha](https://github.com/mochajs/mocha)\n- [Chai](https://github.com/chaijs/chai)\n- [Supertest](https://github.com/visionmedia/supertest)\n- [NPS](https://github.com/kentcdodds/nps)\n- [MongoDB](https://www.mongodb.com/)\n- [Mongoose](http://mongoosejs.com/)\n- [Webpack3](https://webpack.js.org/)\n\n---\n\n## Todo\n\n- [x] Test seeds controller - Done by [cpenarrieta](https://github.com/cpenarrieta)\n- [ ] Sendgrid or Other Mail supply\n- [ ] Add S3 for user image\n- [ ] Change Mocha for Jest\n\n# PR are welcome!!! 😃\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n| [\u003cimg src=\"https://avatars0.githubusercontent.com/u/15819498?v=3\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003eEmanuel Quimper\u003c/sub\u003e](https://equimper.me/)\u003cbr /\u003e[💬](#question-EQuimper \"Answering Questions\") [📝](#blog-EQuimper \"Blogposts\") [🐛](https://github.com/EQuimper/nodejs-api-boilerplate/issues?q=author%3AEQuimper \"Bug reports\") [💻](https://github.com/EQuimper/nodejs-api-boilerplate/commits?author=EQuimper \"Code\") [📖](https://github.com/EQuimper/nodejs-api-boilerplate/commits?author=EQuimper \"Documentation\") [💡](#example-EQuimper \"Examples\") [🚇](#infra-EQuimper \"Infrastructure (Hosting, Build-Tools, etc)\") [🔌](#plugin-EQuimper \"Plugin/utility libraries\") [👀](#review-EQuimper \"Reviewed Pull Requests\") [⚠️](https://github.com/EQuimper/nodejs-api-boilerplate/commits?author=EQuimper \"Tests\") [🔧](#tool-EQuimper \"Tools\") [✅](#tutorial-EQuimper \"Tutorials\") | [\u003cimg src=\"https://avatars0.githubusercontent.com/u/1692542?v=3\" width=\"100px;\"/\u003e\u003cbr /\u003e\u003csub\u003eCristian Penarrieta\u003c/sub\u003e](https://medium.com/@cpenarrieta)\u003cbr /\u003e[⚠️](https://github.com/EQuimper/nodejs-api-boilerplate/commits?author=cpenarrieta \"Tests\") |\n| :---: | :---: |\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEQuimper%2Fnodejs-api-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEQuimper%2Fnodejs-api-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEQuimper%2Fnodejs-api-boilerplate/lists"}