{"id":17436374,"url":"https://github.com/aaronleocooper/hapi-namespaced-routes","last_synced_at":"2025-07-28T19:37:54.758Z","repository":{"id":57260987,"uuid":"109791375","full_name":"AaronLeoCooper/hapi-namespaced-routes","owner":"AaronLeoCooper","description":"A Hapi plugin to load routes with a namespace","archived":false,"fork":false,"pushed_at":"2017-11-09T07:25:19.000Z","size":89,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-07T19:06:29.210Z","etag":null,"topics":["api","hapi","hapi-plugin","namespace","plugin","rest-api","routes"],"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/AaronLeoCooper.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-11-07T05:36:20.000Z","updated_at":"2017-11-07T05:37:21.000Z","dependencies_parsed_at":"2022-08-31T12:22:52.198Z","dependency_job_id":null,"html_url":"https://github.com/AaronLeoCooper/hapi-namespaced-routes","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AaronLeoCooper%2Fhapi-namespaced-routes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AaronLeoCooper%2Fhapi-namespaced-routes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AaronLeoCooper%2Fhapi-namespaced-routes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AaronLeoCooper%2Fhapi-namespaced-routes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AaronLeoCooper","download_url":"https://codeload.github.com/AaronLeoCooper/hapi-namespaced-routes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245954521,"owners_count":20699844,"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":["api","hapi","hapi-plugin","namespace","plugin","rest-api","routes"],"created_at":"2024-10-17T10:09:19.728Z","updated_at":"2025-03-28T01:47:25.600Z","avatar_url":"https://github.com/AaronLeoCooper.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hapi Namepsaced Routes\n\n[![npm version](https://badge.fury.io/js/hapi-namespaced-routes.svg)](https://badge.fury.io/js/hapi-namespaced-routes)\n[![Build Status](https://travis-ci.org/AaronLeoCooper/hapi-namespaced-routes.svg?branch=master)](https://travis-ci.org/AaronLeoCooper/hapi-namespaced-routes)\n[![Coverage Status](https://coveralls.io/repos/github/AaronLeoCooper/hapi-namespaced-routes/badge.svg?branch=master)](https://coveralls.io/github/AaronLeoCooper/hapi-namespaced-routes?branch=master)\n\nA Hapi plugin to enable writing routes with a namespace (prefix) with\na minimal API.\n\n\n## Usage\n\nInstall the module:\n\n```bash\nnpm install hapi-namespaced-routes\n```\n\nThen register it in your Hapi app:\n\n```javascript\nconst server = new Hapi.Server()\n\nserver.register(require('hapi-namespaced-routes'))\n```\n\nAnd finally, add your app routes anywhere you have access to your app\n`server` instance:\n\n```javascript\nserver.methods.namespacedRoute({\n  namespace: '/posts',\n  routes: [\n    {\n      method: 'GET',\n      path: '',\n      handler: postsHandler\n    },\n    {\n      method: 'GET',\n      path: '/comments',\n      handler: commentsHandler\n    }\n  ]\n})\n\n/**\n * Generates these routes:\n *   /posts\n *   /posts/comments\n */\n```\n\n\n## How it works\n\nThe logic in this plugin is deliberately simple: its sole purpose is to prefix\nroutes with a namespace in their path. Once all passed routes have been\nprefixed, they are passed to Hapi's built-in `server.route` method, so anything\nyou add to route objects will also be passed through unaffected.\n\n\n## Todos\n\nIn the interests of keeping this module small I probably won't add a lot of\nextra features. That said, I'm open to ideas!\n\nThese are the currently planned additions sometime in the near future:\n\n- [ ] Ability to inject routes at registration time\n- [ ] \"Global\" namespace option (for auto-wrapping all passed in routes)\n\n\n## Alternatives\n\nOne alternative package I've seen that does a similar job to this plugin is\ndsernst's [hapi-namespace](https://github.com/dsernst/hapi-namespace).\nIt offers an alternative API— opting to use a wrapper function to accept the\nnamespace and routes as parameters, and it doesn't explicitly require Hapi\nsince it doesn't use Hapi's plugin system, so that might be a more favourable\noption depending on your needs.\n\nThere's probably a few other options out there too in the wild. Feel free to\nbring any others to my attention and I'll add those here too!\n\n\n## Tests\n\nThis plugin has unit tests that can be executed by cloning this repo to your\nmachine and running `npm test` after `npm install`. At the time of writing,\npassing tests and test coverge are at 100%.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronleocooper%2Fhapi-namespaced-routes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faaronleocooper%2Fhapi-namespaced-routes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronleocooper%2Fhapi-namespaced-routes/lists"}