{"id":16384758,"url":"https://github.com/saber2pr/koa","last_synced_at":"2026-04-21T09:31:46.081Z","repository":{"id":108571291,"uuid":"182279362","full_name":"Saber2pr/koa","owner":"Saber2pr","description":"koa in typescript","archived":false,"fork":false,"pushed_at":"2019-05-17T12:39:01.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-27T23:04:35.669Z","etag":null,"topics":["koa","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Saber2pr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-04-19T14:43:34.000Z","updated_at":"2019-06-23T06:49:07.000Z","dependencies_parsed_at":"2023-07-18T16:21:38.495Z","dependency_job_id":null,"html_url":"https://github.com/Saber2pr/koa","commit_stats":null,"previous_names":["saber2pr/-saber2pr-koa"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Saber2pr/koa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Fkoa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Fkoa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Fkoa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Fkoa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Saber2pr","download_url":"https://codeload.github.com/Saber2pr/koa/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saber2pr%2Fkoa/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266430671,"owners_count":23927165,"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-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["koa","typescript"],"created_at":"2024-10-11T04:12:17.623Z","updated_at":"2026-04-21T09:31:46.030Z","avatar_url":"https://github.com/Saber2pr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @saber2pr/koa\n\n[![npm](https://img.shields.io/npm/v/@saber2pr/koa.svg?color=blue)](https://www.npmjs.com/package/@saber2pr/koa)\n\n\u003e koa in typescript.\n\n```bash\n# from npm\nnpm install @saber2pr/koa\n\n# from github\ngit clone https://github.com/Saber2pr/-saber2pr-koa.git\n```\n\n## API\n\n1. compose\n\n   \u003e 组合多个 Job\n\n2. Koa\n\n   \u003e 创建一个应用\n\n## Koa.body\n\n这是个很重要的 API，返回 Koa 应用的 reducers !\n\n它能用来做什么我想你已经猜到了 !\n\nIt' s a very useful api, it returns koa-app' s reducers!\n\nI think you have known what it does mean.\n\n# Koa\n\n```ts\nconst user = Koa()\n  .use(async (ctx, next) =\u003e {\n    if (ctx.request.url === '/user') {\n      ctx.response.end('user!')\n    } else {\n      await next()\n    }\n  })\n  .use(async (ctx, next) =\u003e {\n    if (ctx.request.url === '/user/saber2pr') {\n      ctx.response.end('saber2pr!')\n    } else {\n      await next()\n    }\n  })\n\n// main app\nKoa({ version: '0.0.1' })\n  .use(async (ctx, next) =\u003e {\n    if (ctx.request.url === '/') {\n      ctx.response.end('Hello World!')\n    } else {\n      await next()\n    }\n  })\n  .use(async (ctx, next) =\u003e {\n    if (ctx.request.url === '/version') {\n      ctx.response.end(ctx.version)\n    } else {\n      await next()\n    }\n  })\n  // look here!\n  .use(user.body())\n\n  .listen(3000, () =\u003e console.log('http://localhost:3000'))\n```\n\n# Notice(\\*)\n\n- Typescript 的函数参数类型是双向协变的，这不安全！\n\n  例如上面的 user.body()，它所依赖的 ContextType 需要主入口程序的 Context 提供，如果允许双向协变，它不会报错！\n\n  强烈建议开启：--strictFunctionTypes\n\n  ```json\n  {\n    \"compilerOptions\": {\n      \"strictFunctionTypes\": true\n    }\n  }\n  ```\n\n- Koa()中参数对象的 this\n  建议开启 noImplicitThis\n\n  ```json\n  {\n    \"compilerOptions\": {\n      \"noImplicitThis\": true\n    }\n  }\n  ```\n\n---\n\n## start\n\n```bash\nnpm install\n```\n\n```bash\nnpm start\n\nnpm test\n```\n\n\u003e Author: saber2pr\n\n---\n\n## develope and test\n\n\u003e you should write ts in /src\n\n\u003e you should make test in /src/test\n\n\u003e export your core in /src/index.ts!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaber2pr%2Fkoa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaber2pr%2Fkoa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaber2pr%2Fkoa/lists"}