{"id":15284515,"url":"https://github.com/npkgz/koa-magic","last_synced_at":"2026-01-20T03:04:03.611Z","repository":{"id":49597752,"uuid":"123975614","full_name":"npkgz/koa-magic","owner":"npkgz","description":"Koajs supercharged. routing. ready-to-use server","archived":false,"fork":false,"pushed_at":"2022-12-07T01:07:04.000Z","size":185,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-17T05:28:50.065Z","etag":null,"topics":["koa2","koajs","middleware","router","routing","web-application"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/koa-magic","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/npkgz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-05T20:36:39.000Z","updated_at":"2024-09-01T07:27:47.000Z","dependencies_parsed_at":"2023-01-24T12:46:09.019Z","dependency_job_id":null,"html_url":"https://github.com/npkgz/koa-magic","commit_stats":null,"previous_names":["andidittrich/node.koa-magic"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/npkgz/koa-magic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fkoa-magic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fkoa-magic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fkoa-magic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fkoa-magic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npkgz","download_url":"https://codeload.github.com/npkgz/koa-magic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npkgz%2Fkoa-magic/sbom","scorecard":{"id":112689,"data":{"date":"2025-08-04","repo":{"name":"github.com/npkgz/koa-magic","commit":"840490a1a99aa3afeb5311800b3fa3813be5cbd4"},"scorecard":{"version":"v5.2.1-28-gc1d103a9","commit":"c1d103a9bb9f635ec7260bf9aa0699466fa4be0e"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/16 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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#sast"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#token-permissions"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#maintained"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#packaging"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#binary-artifacts"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#license"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#signed-releases"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"20 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-phwq-j96m-2c2q","Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-593f-38f6-jp5m","Warn: Project is vulnerable to: GHSA-x2rg-q646-7m2v","Warn: Project is vulnerable to: GHSA-jgmv-j7ww-jx2x","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","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-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-15T13:48:44.554Z","repository_id":49597752,"created_at":"2025-08-15T13:48:44.554Z","updated_at":"2025-08-15T13:48:44.554Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28594958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"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":["koa2","koajs","middleware","router","routing","web-application"],"created_at":"2024-09-30T14:57:49.065Z","updated_at":"2026-01-20T03:04:03.594Z","avatar_url":"https://github.com/npkgz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"koa-magic\n=========================================\n\nkoa supercharged. middleware library. ready-to-go web-application-server based on [koajs v2](https://github.com/koajs/koa)\n\n## Features ##\n\n* Stackable routing middleware \n* Path-Match Router\n* VHost Router (domain/hostname based)\n* Easy to use application server including basic koa modules\n* Components can be used standalone\n* Cluster support/Hot-Reload via [cluster-magic](https://github.com/AndiDittrich/Node.cluster-magic)\n* Sendfile implementation\n* Static fileserver implementation\n\n## Install ##\n\n```bash\n$ npm install koa-magic --save\n$ yarn add koa-magic\n```\n\n## Modules ##\n\nkoa-magic provides the following modules\n\n```js\nconst {Koa, Router, ApplicationServer, ErrorLogger, Dispatcher} = require('koa-magic');\n```\n\n* [Koa](docs/koa.md) - Extended Koa class including routing methods\n* [Router](docs/router.md) - Stackable - express like - routing middleware\n* [ApplicationServer](docs/application-server.md) - Ready-to-use Koa webserver including basic middleware (compress, sessions) \n* [ErrorLogger](docs/error-logger.md) - error-logging middleware - exceptions are logged by [logging-facility](https://www.npmjs.com/package/logging-facility)\n* [Dispatcher](docs/dispatcher.md) - routing middleware dispatcher (used by Router)\n\n## Koa Extend ##\n\nBasic [Koa Class](https://github.com/koajs/koa/blob/master/lib/application.js) extended by routing methods.\n\n### Examples ###\n\n**Example 1 - path routing**\n```js\nconst Router = require('koa-magic').Router;\nconst Koa = require('koa-magic').Koa;\n\n// initialize koa + router\nconst webapp = new Koa();\nconst myrouter = new Router();\n\n// attach handler to root path\nkoa.get('/helloworld.html', ctx =\u003e {\n    ctx.body = 'Helloworld';\n});\n\n// attach router middleware - use attach() of extended Koa!\nkoa.attach('/hello', myrouter);\n\n// start server\nkoa.listen(...);\n```\n\n## Router ##\n\nThe mount-path is processed by [path-to-regexp](https://github.com/pillarjs/path-to-regexp) to enable parametric path expressions. The parameters are exposed by the `ctx.params` object.\n\n**Note:** use `.attach()` instead of `.use()` to add middleware to the stack. It handles flat middleware functions like `(ctx, next) =\u003e {}` as well as instances of `Router`!\n\n### Methods ##\n\nThe following methods are provided by each routing instance (or extended Koa class)\n\n**HTTP**\n\n* `get(path:string|RegExp, middleware:Promise)` handle http-get\n* `post(path:string|RegExp, middleware:Promise)` handle http-post\n* `put(path:string|RegExp, middleware:Promise)` handle http-put\n* `head(path:string|RegExp, middleware:Promise)` handle http-head\n* `delete(path:string|RegExp, middleware:Promise)` handle http-delete\n* `options(path:string|RegExp, middleware:Promise)` handle http-options\n* `all(path:string|RegExp, middleware:Promise)` handle all kind of http-methods\n\n**VHOST**\n\n* `vhost(hostname:string|RegExp, middleware:Promise|Router`) virtual host routing\n\n**ROUTING**\n\n* `attach(path:string|RegExp, middleware:Promise|Router`) add a new router to the current stack (like use)\n\n### Examples ###\n\n**Example 1 - path routing**\n```js\nconst Router = require('koa-magic').Router;\nconst Koa = require('koa-magic').Koa;\n\n// initialize koa + router\nconst webapp = new Koa();\nconst myrouter = new Router();\n\nmyrouter.get('/world.html', ctx =\u003e {\n    ctx.body = \"ook\";\n});\nmyrouter.post('/:action/:view?', ctx =\u003e {\n    ctx.body = \"action:\" + ctx.params.action + ' - ' + ctx.params.view;\n});\n\n// attach handler to root path\nkoa.get('/helloworld.html', ctx =\u003e {\n    ctx.body = 'Helloworld';\n});\n\n// attach router middleware - use attach() of extended Koa!\nkoa.attach('/hello', myrouter);\n\n// start server\nkoa.listen(...);\n```\n\n**Example 2 - path routing with request forwarding**\n```js\nconst Router = require('koa-magic').Router;\nconst Koa = require('koa-magic').Koa;\n\n// initialize koa + router\nconst webapp = new Koa();\nconst myrouter = new Router();\n\nmyrouter.get('(.*)', (ctx, next) =\u003e {\n    dosomething();\n    return next();\n});\nmyrouter.post('/:action/:view?', ctx =\u003e {\n    ctx.body = \"action:\" + ctx.params.action + ' - ' + ctx.params.view;\n});\n\n// attach router middleware - use attach() of extended Koa!\nkoa.attach('/mymodule', myrouter);\n\n// start server\nkoa.listen(...);\n```\n\n**Example 3 - vhost routing**\n```js\nconst Router = require('koa-magic').Router;\nconst Koa = require('koa-magic').Koa;\n\n// initialize koa + router\nconst webapp = new Koa();\nconst myrouter = new Router();\n\nmyrouter.get('/world.html', ctx =\u003e {\n    ctx.body = \"ook\";\n});\n\n// attach router middleware to domain\nkoa.vhost('example.org', myrouter);\n\n// start server\nkoa.listen(...);\n```\n\n## License ##\nkoa-magic is OpenSource and licensed under the Terms of [The MIT License (X11)](http://opensource.org/licenses/MIT) - your're welcome to contribute\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpkgz%2Fkoa-magic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpkgz%2Fkoa-magic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpkgz%2Fkoa-magic/lists"}