{"id":15253551,"url":"https://github.com/daidr/koa-router-dynamic","last_synced_at":"2026-02-05T07:31:42.601Z","repository":{"id":108063353,"uuid":"418433805","full_name":"daidr/koa-router-dynamic","owner":"daidr","description":"A patch for @koa/router to search for or remove routes without restarting the process.","archived":false,"fork":false,"pushed_at":"2021-10-19T14:04:40.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-13T15:54:29.720Z","etag":null,"topics":["koa","koa-router","koa2"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/koa-router-dynamic","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/daidr.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}},"created_at":"2021-10-18T09:36:09.000Z","updated_at":"2022-08-21T16:37:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"5efb6dde-e198-4713-a34d-5b692eef177a","html_url":"https://github.com/daidr/koa-router-dynamic","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"d683a9d074d45e266676df86612a1847b6b60b84"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/daidr/koa-router-dynamic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidr%2Fkoa-router-dynamic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidr%2Fkoa-router-dynamic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidr%2Fkoa-router-dynamic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidr%2Fkoa-router-dynamic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daidr","download_url":"https://codeload.github.com/daidr/koa-router-dynamic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidr%2Fkoa-router-dynamic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29115530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T05:31:32.482Z","status":"ssl_error","status_checked_at":"2026-02-05T05:31:29.075Z","response_time":65,"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":["koa","koa-router","koa2"],"created_at":"2024-09-29T21:05:25.723Z","updated_at":"2026-02-05T07:31:42.586Z","avatar_url":"https://github.com/daidr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [koa-router-dynamic](https://github.com/daidr/koa-router-dynamic)\n\n\u003e A patch for [@koa/router](https://github.com/koajs/router).\n\n[![NPM version](https://img.shields.io/npm/v/koa-router-dynamic.svg?style=flat)](https://npmjs.org/package/koa-router-dynamic) \n[![NPM Downloads](https://img.shields.io/npm/dm/koa-router-dynamic.svg?style=flat)](https://npmjs.org/package/koa-router-dynamic) \n[![Node.js Version](https://img.shields.io/node/v/koa-router-dynamic.svg?style=flat)](http://nodejs.org/download/)\n\n* Search routes by path(s)\n* Search routes by custom handler\n* Remove routes without restarting the process\n\n## Installation\n\n```bash\n# npm .. \nnpm i koa-router-dynamic\n# yarn .. \nyarn add koa-router-dynamic\n```\n\n## Usage\n\n### router.searchRoutesByPath(path) ⇒ \u003ccode\u003eArray.\u0026lt;Layer\u0026gt;\u003c/code\u003e\nSearch routes in the stack by path(s).\n\n**Kind**: instance method of Router  \n\n| Param | Type                                                     | Description         |\n|-------|----------------------------------------------------------|---------------------|\n| path  | \u003ccode\u003eString\u003c/code\u003e \\| \u003ccode\u003eArray.\u0026lt;String\u0026gt;\u003c/code\u003e | Path string(Array). |\n\n**Example**  \n```javascript\nconst Koa = require('koa');\nconst Router = require('@koa/router');\nrequire('koa-router-dynamic');\n\nconst app = new Koa();\nconst router = new Router();\n\nrouter.get(\"/example/:id\", ctx =\u003e {\n  ctx.body = \"test\";\n})\n\napp.use(router.routes());\n\nconsole.log(router.searchRoutesByPath(\"/example/:id\"));\n```\n\n### router.searchRoutes(handler) ⇒ \u003ccode\u003eArray.\u0026lt;Layer\u0026gt;\u003c/code\u003e\nSearch routes in the stack by custom handler.\n\n**Kind**: instance method of Router\n\n| Param   | Type                  | Description       |\n|---------|-----------------------|-------------------|\n| handler | \u003ccode\u003efunction\u003c/code\u003e | Handler function. |\n\n**Example**  \n```javascript\nconst Koa = require('koa');\nconst Router = require('@koa/router');\nrequire('koa-router-dynamic');\n\nconst app = new Koa();\nconst router = new Router();\n\nrouter.get(\"/example/:id\", ctx =\u003e {\n  ctx.body = \"test\";\n})\n\napp.use(router.routes());\n\nconsole.log(router.searchRoutes(layer =\u003e layer.path === \"/example/:id\"));\n```\n\n\n### router.removeAllRoutes() ⇒ \u003ccode\u003eRouter\u003c/code\u003e\nRemove all routes in the stack.\n\n**Kind**: instance method of Router\n**Example**  \n```javascript\nconst Koa = require('koa');\nconst Router = require('@koa/router');\nrequire('koa-router-dynamic');\n\nconst app = new Koa();\nconst router = new Router();\n\nrouter.get(\"/example/:id\", ctx =\u003e {\n  ctx.body = \"test\";\n})\n\napp.use(router.routes());\n\nrouter.removeAllRoutes();\n```\n\n### router.removeRoutes(layers) ⇒ \u003ccode\u003eRouter\u003c/code\u003e\nRemove routes in the stack.\n\n**Kind**: instance method of Router\n\n| Param  | Type                                                   | Description       |\n|--------|--------------------------------------------------------|-------------------|\n| layers | \u003ccode\u003eLayer\u003c/code\u003e \\| \u003ccode\u003eArray.\u0026lt;Layer\u0026gt;\u003c/code\u003e | layers to remove. |\n\n**Example**  \n```javascript\nconst Koa = require('koa');\nconst Router = require('@koa/router');\nrequire('koa-router-dynamic');\n\nconst app = new Koa();\nconst router = new Router();\n\nrouter.get(\"/example/:id\", ctx =\u003e {\n  ctx.body = \"test\";\n})\n\napp.use(router.routes());\n\nlet routesToRemove = router.searchRoutes(layer =\u003e layer.path === \"/example/:id\");\nrouter.removeRoutes(routesToRemove);\n```\n\n## Contributing\n\nPlease submit all issues and pull requests to the [daidr/koa-router-dynamic](http://github.com/daidr/koa-router-dynamic) repository!\n\n## Support\n\nIf you have any problem or suggestion please open an issue [here](https://github.com/daidr/koa-router-dynamic/issues).\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaidr%2Fkoa-router-dynamic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaidr%2Fkoa-router-dynamic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaidr%2Fkoa-router-dynamic/lists"}