{"id":26674176,"url":"https://github.com/0xh3xa/nodstarter","last_synced_at":"2026-01-27T12:36:48.925Z","repository":{"id":56596174,"uuid":"243521865","full_name":"0xh3xa/nodstarter","owner":"0xh3xa","description":"Starter application for Node.js to provide rapid Restful APIs development, pre-configured, secured routers, services, and models","archived":false,"fork":false,"pushed_at":"2025-06-05T14:39:26.000Z","size":6053,"stargazers_count":1,"open_issues_count":17,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-19T03:10:56.456Z","etag":null,"topics":["auth","backend","bcrypt","body-parser","chai","express-jwt","expressjs","javascript","jwt","lodash","method-override","mocha","mongodb","mongoose","morgan-middleware","nodejs","pre-configured","rest-api","starter","supertest"],"latest_commit_sha":null,"homepage":"https://0xh3xa.github.io/nodstarter","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xh3xa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2020-02-27T13:08:32.000Z","updated_at":"2024-08-22T18:22:43.000Z","dependencies_parsed_at":"2022-08-15T21:40:20.899Z","dependency_job_id":"39c87138-a5d7-445a-92c6-a0ad8b6d9147","html_url":"https://github.com/0xh3xa/nodstarter","commit_stats":{"total_commits":37,"total_committers":2,"mean_commits":18.5,"dds":0.2702702702702703,"last_synced_commit":"71746985db3df0795e2990e00ffd88bdb69be024"},"previous_names":["ahmadmoawad/nodstarter","ahmadmoaw/nodstarter","0xh3xa/nodstarter"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/0xh3xa/nodstarter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xh3xa%2Fnodstarter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xh3xa%2Fnodstarter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xh3xa%2Fnodstarter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xh3xa%2Fnodstarter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xh3xa","download_url":"https://codeload.github.com/0xh3xa/nodstarter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xh3xa%2Fnodstarter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28813215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: 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":["auth","backend","bcrypt","body-parser","chai","express-jwt","expressjs","javascript","jwt","lodash","method-override","mocha","mongodb","mongoose","morgan-middleware","nodejs","pre-configured","rest-api","starter","supertest"],"created_at":"2025-03-26T02:17:42.712Z","updated_at":"2026-01-27T12:36:48.909Z","avatar_url":"https://github.com/0xh3xa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Nodstarter\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/0xh3xa/nodstarter/blob/master/asset/logo_1.png\" alt=\"nodstarter\" width=\"150\" height=\"150\"/\u003e\n\u003c/p\u003e\n\u003cbr/\u003e\n\n\u003cdiv\u003e\n      \u003cp\u003e\n            Nodstarter is a starter application for Node.js designed to facilitate rapid RESTful API development. It provides pre-configured, secured routers, services, and models to streamline the creation of secure and scalable applications.\n      \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/nodstarter\"\u003e\n    \u003cimg src=\"https://img.shields.io/static/v1?label=build\u0026message=passing\u0026color=light-green\u0026style=flat\" alt=\"Build Status\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/nodstarter\"\u003e\n    \u003cimg src=\"https://img.shields.io/static/v1?label=dependencies\u0026message=passing\u0026color=light-green\u0026style=flat\" alt=\"Dependency Status\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/nodstarter\"\u003e\n    \u003cimg src=\"https://img.shields.io/static/v1?label=linux\u0026message=passing\u0026color=green\u0026style=flat\" alt=\"Linux\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/nodstarter\"\u003e\n    \u003cimg src=\"https://img.shields.io/static/v1?label=macos\u0026message=passing\u0026color=green\u0026style=flat\" alt=\"Mac\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://snyk.io/test/github/dwyl/hapi-auth-jwt2?targetFile=package.json\"\u003e\n    \u003cimg src=\"https://snyk.io/test/github/dwyl/hapi-auth-jwt2/badge.svg?targetFile=package.json\" alt=\"Known Vulnerabilities\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/nodstarter\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/0xh3xa/nodstarter\" alt=\"License\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n## Table of Contents\n\n- [General Info](#general-info)\n- [Technologies](#technologies)\n- [Initial Code](#initial-code)\n- [Project Structure](#project-structure)\n- [Code Example](#code-example)\n- [Sign In API Call Example](#sign-in-api-call-example)\n- [Environment Variables](#environment-variables)\n- [Setup](#setup)\n- [Before Running](#before-running)\n- [Demo](#demo)\n- [New Ideas](#new-ideas)\n- [Future Plans](#future-plans)\n- [Contributing](#contributing)\n- [License Summary](#license-summary)\n- [NPM Statistics](#npm-statistics)\n- [Project Based](#project-based)\n\n## General Info\n\nNodstarter provides a framework for developing secure RESTful APIs quickly. It includes pre-configured routers, services, and models, allowing developers to focus on writing business logic rather than setup and configuration.\n\n## Technologies\n\n- **Node.js**: JavaScript runtime for building scalable network applications.\n- **Express**: Web framework for Node.js.\n- **MongoDB**: NoSQL database for storing data.\n- **Mongoose**: ORM for MongoDB.\n- **Lodash**: Utility library for JavaScript.\n- **Morgan**: HTTP request logger middleware.\n- **Body-parser**: Middleware for parsing request bodies.\n- **Method-override**: Middleware to allow HTTP verbs such as PUT or DELETE.\n- **Bcrypt**: Library for hashing passwords.\n- **Express-jwt**: Middleware for JWT authentication.\n- **Jsonwebtoken**: Library for signing and verifying JSON Web Tokens.\n- **Cors**: Middleware for enabling Cross-Origin Resource Sharing.\n- **Nodemon**: Utility for auto-reloading the server during development.\n- **Testing Libraries**: Supertest, Chai, and Mocha for testing.\n\n## Initial Code\n\nNodstarter includes models for `users`, `posts`, and `categories`, with predefined relationships:\n\n- **User to Posts**: One-to-many.\n- **Posts to Categories**: Many-to-many.\n\nThese components are organized into routers, controllers, and models to provide a clear structure for API development.\n\n## Project structure\n\n``` \n├── index.js\n├── package.json\n├── scripts\n│   └── post_install.js\n└── server\n    ├── api\n    │   ├── categories\n    │   │   ├── controller.js\n    │   │   ├── model.js\n    │   │   └── router.js\n    │   ├── index.js\n    │   ├── posts\n    │   │   ├── controller.js\n    │   │   ├── model.js\n    │   │   └── router.js\n    │   └── users\n    │       ├── controller.js\n    │       ├── model.js\n    │       └── router.js\n    ├── auth\n    │   ├── controller.js\n    │   ├── index.js\n    │   └── routers.js\n    ├── config\n    │   ├── development.js\n    │   ├── index.js\n    │   ├── production.js\n    │   └── testing.js\n    ├── index.js\n    ├── middleware\n    │   ├── err.js\n    │   └── index.js\n    └── util\n        ├── createRouter.js\n        └── logger.js\n```\n\n## Code example\n\nThis is the configuration to the JWT token to the user\n\n#### JWT configuration\n\n``` js\nconst expressJwt = require('express-jwt');\nconst config = require('../config');\nconst logger = require('../util/logger');\nconst jwt = require('jsonwebtoken');\nconst checkToken = expressJwt({\n    secret: config.secrets.jwt\n});\nconst User = require('../api/users/model');\nexports.decodeToken = () =\u003e {\n    return (req, res, next) =\u003e {\n        if (req.query \u0026\u0026 req.query.hasOwnProperty('access_token')) {\n            req.headers.authorization = 'Bearer ' + req.query.access_token;\n        }\n        checkToken(req, res, next);\n    };\n};\n\nexports.getFreshUser = () =\u003e {\n    return (req, res, next) =\u003e {\n        User.findById(req.user._id)\n            .then((user) =\u003e {\n                if (!user) {\n                    res.status(400).send('Unanuthorized');\n                } else {\n                    req.user = user;\n                    next();\n                }\n            }, (err) =\u003e {\n                next(err);\n            });\n    };\n};\n\nexports.verifyUser = () =\u003e {\n    return (req, res, next) =\u003e {\n        var username = req.body.username;\n        var password = req.body.password;\n\n        if (!username || !password) {\n            res.status(400).send('You need a username and password');\n            return;\n        }\n\n        User.findOne({\n                username: username\n            })\n            .then((user) =\u003e {\n                logger.log('the selected user from DB: ' + user);\n                if (!user) {\n                    logger.log('No user with the given username');\n                    res.status(401).send('Invalid username or password');\n                } else if (!user.authenticate(password)) {\n                    logger.log('Invalid password');\n                    res.status(401).send('Invalid username or password');\n                } else {\n                    req.user = user;\n                    next();\n                }\n            }, (err) =\u003e {\n                next(err);\n            });\n    };\n};\n\nexports.signToken = (id) =\u003e {\n    logger.log(\"id is: \" + id);\n    return jwt.sign({\n        _id: id\n    }, config.secrets.jwt, {\n        expiresIn: config.expireTime\n    });\n};\n```\n\n## Sign in API call example\n\n``` sh\ncurl --header \"Content-Type: application/json\" --request POST --data '{\"username\":\"test_user_4\",\"password\":\"12345\"}' http://localhost:3000/auth/signin\n```\n\n, `Output`\n\n``` \n{\"token\":\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZTY2NjQwODYzMGE0NDE3MThiMjNhMzgiLCJpYXQiOjE1ODQ2Mzc4NDIsImV4cCI6MTU4NDY1MjI0Mn0.MODWP86ebc8XOMjDGyuvNCWWoKnQhpZpl81ynFGExG8\"}\n```\n\n## Environment variables\n\nNodstarter starts searching first for the following environment variables if found them will use them if not will use the default. The default values for `NODE_ENV` is development, `NODE_PORT` is `3000` and `JWT` is `Gambell`\nYou can choose the environment for the `NODE_ENV` variable from one of the following profiles (`development`, `production`, `testing`)\n\n01. `NODE_ENV`\n02. `NODE_PORT`\n03. `JWT`\n\n## Setup\n\n1. Init with [npm][npmjs-url]:\n\n``` sh\n$ npm init\n```\n\n2. Install:\n\n``` sh\n$ npm install nodstarter\n```\n\n3. Start:\n\n``` sh\n$ npm start\n```\n\n, or use in one-line command:\n\n``` sh\n$ npm init; npm install nodstarter; npm start\n```\n\n### Before running\n\nPlease make sure that the `MongoDB daemon` is up and running\n\n* Ubuntu\n\n```\nsystemctl start mongodb\n```\n\n* Macos\n\n```\nbrew services run mongodb-community\n```\n\n## Demo\n\n![Demo][demo-url]\n\n## Running Tests (future plan)\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n``` sh\n$ npm install \u0026\u0026 npm test\n```\n\n## Future plans\n\n1. Swagger file for the existing APIs\n2. Add tests for the existing APIs\n3. Ability to make nodstarter a command line to install models, controllers and routers, etc.\n\n## New Ideas\n\nIf you have new ideas about the project please describe what you want to do and changes using an issue.\n\n## Contributing \n\nSee [CONTRIBUTING.md](.github/CONTRIBUTING.md)\n\n## License summary\n\nSee \u003ca href=\"https://github.com/0xh3xa/nodstarter/blob/develop/LICENSE\"/\u003eLicense\u003c/a\u003e\n\n## NPM statistics\n\n[![NPM](https://nodei.co/npm/nodstarter.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/nodstarter/)\n\n## Project based\n\n\u003ca href=\"https://github.com/0xh3xa/nodstarter\"\u003e\u003cimg src=\"https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2Fd%2Fd9%2FNode.js_logo.svg%2F1920px-Node.js_logo.svg.png\u0026f=1\u0026nofb=1\" alt=\"nodejs\" width=\"200\" height=\"110\"/\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ca href=\"https://github.com/0xh3xa/nodstarter\"\u003e\u003cimg src=\"https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fcamo.githubusercontent.com%2Ffc61dcbdb7a6e49d3adecc12194b24ab20dfa25b%2F68747470733a2f2f692e636c6f756475702e636f6d2f7a6659366c4c376546612d3330303078333030302e706e67\u0026f=1\u0026nofb=1\" alt=\"nodejs\" width=\"250\" height=\"110\"/\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003ca href=\"https://github.com/0xh3xa/nodstarter\"\u003e\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/MongoDB_Logo.svg/768px-MongoDB_Logo.svg.png?20190626143224\" alt=\"nodejs\" width=\"250\" height=\"110\"/\u003e\u003c/a\u003e\n\n[demo-url]: https://github.com/0xh3xa/nodstarter/raw/master/asset/demo.gif\n[build-img]: https://img.shields.io/static/v1?label=build\u0026message=passing\u0026color=light-green\u0026style=flat\n[depend-img]: https://img.shields.io/static/v1?label=dependencies\u0026message=passing\u0026color=light-green\u0026style=flat\n[nodestarter-url]: https://www.npmjs.com/package/nodstarter\n[starter-img]: https://img.shields.io/static/v1?label=nod\u0026message=starter\u0026color=blue\u0026style=flat\n[starter-url]: [nodestarter-url]\n[nodejs-img]: https://img.shields.io/static/v1?label=nodejs\u0026message=12.0.0\u0026color=orange\u0026style=flat\n[nodejs-url]: [nodestarter-url]\n[npm-img]: https://img.shields.io/static/v1?label=npm\u0026message=6.0.0\u0026color=pink\u0026style=flat\n[npm-url]: [nodestarter-url]\n[npmjs-url]: https://www.npmjs.com/\n[linux-img]: https://img.shields.io/static/v1?label=linux\u0026message=passing\u0026color=green\u0026style=flat\n[macos-img]: https://img.shields.io/static/v1?label=macos\u0026message=passing\u0026color=green\u0026style=flat\n[linux-url]: [nodestarter-url]\n[license-img]: https://img.shields.io/github/license/0xh3xa/nodstarter\n[license-url]: [nodestarter-url]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xh3xa%2Fnodstarter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xh3xa%2Fnodstarter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xh3xa%2Fnodstarter/lists"}