{"id":22447119,"url":"https://github.com/imajkumar/node_api_express","last_synced_at":"2026-04-13T01:37:02.019Z","repository":{"id":116862557,"uuid":"173731094","full_name":"imajkumar/node_api_express","owner":"imajkumar","description":"This api for TODO and budget planer","archived":false,"fork":false,"pushed_at":"2019-05-02T09:54:50.000Z","size":95,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-27T00:18:14.603Z","etag":null,"topics":["jwt","mongo","nodejs","passport"],"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/imajkumar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-03-04T11:20:24.000Z","updated_at":"2019-05-02T09:54:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"6117ad24-e490-43da-90c9-2a129173c5e0","html_url":"https://github.com/imajkumar/node_api_express","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/imajkumar/node_api_express","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imajkumar%2Fnode_api_express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imajkumar%2Fnode_api_express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imajkumar%2Fnode_api_express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imajkumar%2Fnode_api_express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imajkumar","download_url":"https://codeload.github.com/imajkumar/node_api_express/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imajkumar%2Fnode_api_express/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31736723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T22:19:12.206Z","status":"ssl_error","status_checked_at":"2026-04-12T22:18:33.088Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["jwt","mongo","nodejs","passport"],"created_at":"2024-12-06T04:14:27.076Z","updated_at":"2026-04-13T01:37:02.011Z","avatar_url":"https://github.com/imajkumar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js express.js MongoDB JWT REST API - Basic Project Skeleton\n\n[![Author](http://img.shields.io/badge/author-@davellanedam-blue.svg?style=flat-square)](https://twitter.com/davellanedam)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://github.com/davellanedam/node-express-mongodb-jwt-rest-api-skeleton/blob/master/LICENSE)\n[![Release](https://img.shields.io/github/release/davellanedam/node-express-mongodb-jwt-rest-api-skeleton.svg?style=flat-square)](https://github.com/davellanedam/node-express-mongodb-jwt-rest-api-skeleton/releases)\n\n## Getting started\n\nThis is a basic API REST skeleton written on JavaScript using async/await. Great for building an MVP for your front-end app (Vue, react, angular, or anything that can consume an API)\n\nThis project is created to help other developers create a **basic REST API in an easy way with Node.js**. This basic example shows how powerful and simple JavaScript can be. Do you want to contribute? Pull requests are always welcome to show more features.\n\n## Features\n\n- Multiple environment ready (development, production)\n- Custom email/password user system with basic security and blocking for preventing brute force attacks.\n- Compressed responses.\n- Secured HTTP headers.\n- CORS ready.\n- Cache ready (Redis)\n- HTTP request logger in development mode.\n- i18n ready (for sending emails in multiple languages)\n- User roles.\n- Pagination ready.\n- User profile.\n- Users list for admin area.\n- Cities model and controller example.\n- Login access log with IP, browser and country location (for country it looks for the header `cf-ipcountry` that CloudFlare creates when protecting your website).\n- API autogenerated documentation by Postman.\n- API collection example for Postman.\n- Testing with mocha/chai for API endpoints.\n- NPM scripts for cleaning and seeding the MongoDB database.\n- NPM script for keeping good source code formatting using prettier and ESLint.\n- Use of ESLint for good coding practices.\n- Mailer example with Nodemailer and Mailgun.\n- JWT Tokens, make requests with a token after login with `Authorization` header with value `Bearer yourToken` where `yourToken` is the **signed and encrypted token** given in the response from the login process.\n\n## Requirements\n\n- Node.js **8+**\n- MongoDB **3.6+**\n- Redis **5.0+**\n\n## How to install\n\n### Using Git (recommended)\n\n1. Clone the project from github. Change \"myproject\" to your project name.\n\n```bash\ngit clone https://github.com/davellanedam/node-express-mongodb-jwt-rest-api-skeleton.git ./myproject\n```\n\n### Using manual download ZIP\n\n1. Download repository\n2. Uncompress to your desired directory\n\n### Install npm dependencies after installing (Git or manual download)\n\n```bash\ncd myproject\nnpm install\nnpm update\n```\n\n### Setting up environments (development or production)\n\n1. In the root this repository you will find a file named `.env.example`\n2. Create a new file by copying and pasting the file and then renaming it to just `.env`\n3. The file `.env` is already ignored, so you never commit your credentials.\n4. Change the values of the file to your environment (development or production)\n5. Upload the `.env` to your environment server(development or production)\n6. If you use the postman collection to try the endpoints, change value of the variable `server` on your environment to the url of your server, for development mode use http://localhost:3000\n\n### Mailer\n\nTo ensure the deliverability of emails sent by this API, `Mailgun` is used for mailing users when they sign up, so if you want to use that feature go sign up at their website https://www.mailgun.com\n\nIf you want to try a different method it´s ok, I used https://nodemailer.com for this API and they have different transport methods like: smtp.\n\n### i18n\n\nLanguage is automatically detected from `Accept-Language` header on the request. So either you send locale manually on the request or your browser will send its default, if `Accept-Language` header is not sent then it will use `en` locale as default.\n\n## How to run\n\n### Database cleaning and seeding samples\n\nThere are 3 available commands for this: `fresh`, `clean` and `seed`.\n\n```bash\nnpm run command\n```\n\n- `fresh` cleans and then seeds the database with dynamic data.\n- `clean` cleans the database.\n- `seed` seeds the database with dynamic data.\n\n### Running in development mode (lifting API server)\n\n```bash\nnpm run dev\n```\n\nYou will know server is running by checking the output of the command `npm run dev`\n\n```bash\n****************************\n*    Starting Server\n*    Port: 3000\n*    NODE_ENV: development\n*    Database: MongoDB\n*    DB Connection: OK\n****************************\n```\n\n### Running tests\n\nIt´s a good practice to do tests at your code, so a sample of how to do that in `mocha/chai` is also included in the `/test` directory\n\n```bash\nnpm run test\n```\n\n### Formatting code\n\nFormat your code with prettier by typing:\n\n```bash\nnpm run format\n```\n\n## Usage\n\nOnce everything is set up to test API routes either use Postman or any other api testing application. Default username/password combination for login is `admin@admin.com/12345`.\n\n### API documentation\n\nhttps://documenter.getpostman.com/view/487539/RWaHwoLV\n\n### Postman API example collection\n\nYou can import the example collection to Postman\n\nhttps://www.getpostman.com/collections/d1e27b60e0ccff22a516\n\nIf you use Postman please go to `manage environments` and then create one for each of your servers (Ex. myApi-LOCAL, myApi-PRODUCTION). \n\nOn each of the environments you create you will need to:\n\n1. Create a new key `authToken` with `token` value (the token you got from the login process), each time you make a request to the API it will send `Authorization` header with the token value in the request, you can check this on the headers of users or cities endpoints in the Postman example.\n2. Create a second key `server` with the url of your server, for development mode use http://localhost:3000\n\nThis is a REST API, so it works using the following HTTP methods:\n\n- GET (Read): Gets a list of items, or a single item\n- POST (Create): Creates an item\n- PATCH (Update): Updates an item\n- DELETE: Deletes an item\n\n### Creating new models\n\nIf you need to add more models to the project just create a new file in `/app/models/` and it will be loaded dynamically.\n\n### Creating new routes\n\nIf you need to add more routes to the project just create a new file in `/app/routes/` and it will be loaded dynamically.\n\n### Creating new controllers\n\nWhen you create a new controller file, try to also create another file with validations. Ex. `countries.js` `countries.validate.js` An example of this is included in the repository.\n\n## Bugs or improvements\n\nFeel free to report any bugs or improvements. Pull requests are always welcome.\n\n## I love this! How can I help?\n\nIt´s amazing you feel like that! Send me a tweet https://twitter.com/davellanedam, share this with others, make a pull request or if you feel really thankful you can always buy me a beer! Enjoy!\n\n## License\n\nThis project is open-sourced software licensed under the MIT License. See the LICENSE file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimajkumar%2Fnode_api_express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimajkumar%2Fnode_api_express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimajkumar%2Fnode_api_express/lists"}