{"id":19425521,"url":"https://github.com/sami-radi/express-vhosts-autoloader","last_synced_at":"2025-10-09T13:37:13.203Z","repository":{"id":143879001,"uuid":"50923228","full_name":"Sami-Radi/express-vhosts-autoloader","owner":"Sami-Radi","description":"Autoloads express middlewares using the hostname as the module foldername.","archived":false,"fork":false,"pushed_at":"2021-09-16T11:00:02.000Z","size":1186,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-21T00:54:31.223Z","etag":null,"topics":["express","express-js","express-middleware","expressjs","javascript","node","node-js","nodejs","virtual-hosts"],"latest_commit_sha":null,"homepage":null,"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/Sami-Radi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-02-02T13:42:52.000Z","updated_at":"2021-09-16T10:59:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"8d7ef719-b44b-41f3-b8f4-7ee814ac66c6","html_url":"https://github.com/Sami-Radi/express-vhosts-autoloader","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Sami-Radi/express-vhosts-autoloader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sami-Radi%2Fexpress-vhosts-autoloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sami-Radi%2Fexpress-vhosts-autoloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sami-Radi%2Fexpress-vhosts-autoloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sami-Radi%2Fexpress-vhosts-autoloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sami-Radi","download_url":"https://codeload.github.com/Sami-Radi/express-vhosts-autoloader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sami-Radi%2Fexpress-vhosts-autoloader/sbom","scorecard":{"id":125549,"data":{"date":"2025-08-11","repo":{"name":"github.com/Sami-Radi/express-vhosts-autoloader","commit":"27215f39584966eeba6360c16bc59727b8491e25"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"27 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-h452-7996-h45h","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc","Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T03:44:34.739Z","repository_id":143879001,"created_at":"2025-08-16T03:44:34.740Z","updated_at":"2025-08-16T03:44:34.740Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001489,"owners_count":26083102,"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-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["express","express-js","express-middleware","expressjs","javascript","node","node-js","nodejs","virtual-hosts"],"created_at":"2024-11-10T14:03:50.096Z","updated_at":"2025-10-09T13:37:13.173Z","avatar_url":"https://github.com/Sami-Radi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Codacy Badge][codacy-image]][codacy-url]\n[![Build Status][circleci-image]][circleci-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n[![License][license-image]][license-url]\n\n# Express VHosts Autoloader\n\nThis module helps you create an Express JS server with virtual hosts auto and manual management.\n\n## Install\n\n```sh\nnpm install express-vhosts-autoloader\n```\n\n## Usage\n\nThis module autoloads your express app's as express middlewares when their directories matches the domain name.\n\nYour directory names **must** be the same as your domain names in order for this module to work.\n\nLet's assume you have this directory structure :\n\nMy Server Directory :\n\n-   `server.js`\n\n-   `node_modules`\n\n    -   `express`\n    -   `express-vhosts-autoloader`\n\n-   `www.nodeapp1.com`\n\n    -   `app.js `\n\n-   `www.nodeapp2.com`\n\n    -   `app.js`\n\n-   `www.nodeapp3.com`\n    -   `app.js`\n\nAnd your domain names (pointing to your server) are :\n\n-   `www.nodeapp1.com`\n-   `www.nodeapp2.com`\n-   `www.nodeapp3.com`\n\n```javascript\n// Load express.\nvar express = require(\"express\");\n\n// Load express vhosts autoloader.\nvar vhostsAutoloader = require(\"express-vhosts-autoloader\");\n\n// Create express server.\nvar expressServer = express();\n\n// Trigger vhostsAutoloader with expressServer as parameter.\nvhostsAutoloader(expressServer);\n\n// Start your express web server\nvar port = process.env[\"PORT\"] || 80;\nvar server = expressServer.listen(port, function () {\n  console.log(\"Server listening on port %d \", port);\n});\n```\n\nIt works !\n\nThe express vhosts autoloader will load each app.js module in each directory as an express middleware triggered only when the required host (i.e domain name) is provided.\n\nEach `app.js` middleware should end with something like `module.exports.app = app` or `exports.app = app`\n\n## API\n\n### `Promise` \u003c= vhostsAutoloader(expressServer, options)\n\nThis function tries to load any `app.js` file in any directory in the server root directory as an express middleware trigger only when the required domain name is provider in the request.\n\n-   `expressServer` (object, **required**) express server instance.\n\n-   `options` : (object, optional).\n    -   `options.debug` (boolean, optional) : defaults to `false`. If `true` makes the module more verbose in the console.\n    -   `options.directory` (string, optional) : defaults to server root directory. If set `vhostsAutoloader` tries to load any `app.js` from the directory provided.\n    -   `options.ignoreList` (array, optional) : defaults to `[\".git\",\".vscode\",\".circleci\",\".nyc_output\",\"log\",\"logs\",\"test\",\"tests\",\"coverage\",\"node_modules\"]`\n\n#### Example\n\n```javascript\n// Tries to load any file in directories located inside /home/user\nvhostsAutoloader(expressServer, {\n  directory: \"/home/user\",\n});\n```\n\n### `Promise` \u003c= vhostsAutoloader.loadVhost(options)\n\nThis utility method loads an express middleware triggered only when the required host (i.e domain name) is provided.\n\n-   `options` : (object, **required**).\n    -   `options.debug` (boolean) : defaults to `false`. If `true` makes the module more verbose in the console.\n    -   `options.domainName` (string, **required**) : the domain name / directory name\n    -   `options.mainFile` (string, optional) : defaults to `'app'`. If set the method will try to load the file named after the provided value.\n    -   `options.exportsProperty` (string, optional) : defaults to `'app'`. If set the method will try to use the exports property named after the provided value\n    -   `options.expressServer` (object, optional | required) : Optional if used after calling `vhostsAutoloader`. **Required** if `vhostsAutoloader.loadVhost` is used alone.\n    -   `options.directory` (object, optional) : defaults to server root directory. If set `vhostsAutoloader.loadVhost` tries to load the module from the `directory\\domainName` directory.\n\n#### Examples\n\nUsed **after calling** `vhostsAutoloader`\n\n```javascript\nvhostsAutoloader.loadVhost({\n  domainName: \"www.foo.com\",\n});\n```\n\nFor `www.foo.com` directory `.\\www.foo.com` will be served and `app.js` module required, needs `module.exports.app` to be set in `app.js`.\n\n```javascript\nvhostsAutoloader.loadVhost({\n  domainName: \"www.foobar.com\",\n  mainFile: \"index\",\n});\n```\n\nFor `www.foobar.com` directory `.\\www.foobar.com` will be served and `index.js` module required, needs `module.exports.index` to be set in `index.js`.\n\n```javascript\nvhostsAutoloader.loadVhost({\n  domainName: \"www.foobarfoo.com\",\n  mainFile: \"index\",\n  exportsProperty: \"bar\",\n});\n```\n\nFor `www.foobarfoo.com` directory `.\\www.foobarfoo.com` will be served, `index.js` module required, needs `module.exports.bar` to be set in `index.js`.\n\nUsed **without calling** `vhostsAutoloader`\n\n```javascript\n// Load express.\nvar express = require(\"express\");\n// Load express vhosts autoloader.\nvar vhostsAutoloader = require(\"express-vhosts-autoloader\");\n// Create express server.\nvar expressServer = express();\n\nvhostsAutoloader.loadVhost({\n  domainName: \"www.foobarfoo.com\",\n  mainFile: \"foo\",\n  exportsProperty: \"bar\",\n  expressServer: expressServer,\n});\n```\n\nFor `www.foobarfoo.com` directory `.\\www.foobarfoo.com` will be served, `foo.js` module required, needs `module.exports.bar` to be set in `foo.js`.\n\n## License\n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/express-vhosts-autoloader\n[npm-url]: https://npmjs.org/package/express-vhosts-autoloader\n[downloads-image]: https://img.shields.io/npm/dw/express-vhosts-autoloader\n[downloads-url]: https://npmjs.org/package/express-vhosts-autoloader\n[circleci-image]: https://img.shields.io/circleci/build/github/Sami-Radi/express-vhosts-autoloader/master\n[circleci-url]: https://circleci.com/gh/Sami-Radi/express-vhosts-autoloader/tree/master\n[coveralls-image]: https://coveralls.io/repos/github/Sami-Radi/express-vhosts-autoloader/badge.svg?branch=master\n[coveralls-url]: https://coveralls.io/github/Sami-Radi/express-vhosts-autoloader?branch=master\n[codacy-image]: https://app.codacy.com/project/badge/Grade/8123da10bc2b4a888c2886db6104cf35\n[codacy-url]: https://www.codacy.com/gh/Sami-Radi/express-vhosts-autoloader/dashboard\n[license-image]: https://img.shields.io/npm/l/express-vhosts-autoloader\n[license-url]: https://github.com/Sami-Radi/express-vhosts-autoloader/blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsami-radi%2Fexpress-vhosts-autoloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsami-radi%2Fexpress-vhosts-autoloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsami-radi%2Fexpress-vhosts-autoloader/lists"}