{"id":13779885,"url":"https://github.com/koajs/route","last_synced_at":"2025-05-15T08:11:01.114Z","repository":{"id":11675658,"uuid":"14185551","full_name":"koajs/route","owner":"koajs","description":"Simple route middleware","archived":false,"fork":false,"pushed_at":"2024-09-16T00:38:28.000Z","size":227,"stargazers_count":449,"open_issues_count":9,"forks_count":46,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-28T07:46:01.974Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/koajs.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-11-06T21:04:46.000Z","updated_at":"2025-01-11T00:25:35.000Z","dependencies_parsed_at":"2024-11-06T08:29:29.847Z","dependency_job_id":"e1d659a7-73a1-456a-a5e7-52a14122facd","html_url":"https://github.com/koajs/route","commit_stats":{"total_commits":76,"total_committers":20,"mean_commits":3.8,"dds":0.6447368421052632,"last_synced_commit":"415add6945d5c96b387205e075b599d09ff1f70b"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Froute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Froute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Froute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Froute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koajs","download_url":"https://codeload.github.com/koajs/route/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252036036,"owners_count":21684228,"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":[],"created_at":"2024-08-03T18:01:10.202Z","updated_at":"2025-05-15T08:11:01.090Z","avatar_url":"https://github.com/koajs.png","language":"JavaScript","readme":"# koa-route\n\n Uber simple route middleware for koa.\n\n```js\nconst _ = require('koa-route');\napp.use(_.get('/pets', pets.list));\napp.use(_.get('/pets/:name', pets.show));\n```\n\n If you need a full-featured solution check out [koa-router](https://github.com/koajs/router),\n a Koa clone of express-resource.\n\n## Installation\n\n```js\n$ npm install koa-route\n```\n\n## Example\n\n  Contrived resource-oriented example:\n\n```js\nconst _ = require('koa-route');\nconst Koa = require('koa');\nconst app = new Koa();\n\nconst db = {\n  tobi: { name: 'tobi', species: 'ferret' },\n  loki: { name: 'loki', species: 'ferret' },\n  jane: { name: 'jane', species: 'ferret' }\n};\n\nconst pets = {\n  list: (ctx) =\u003e {\n    const names = Object.keys(db);\n    ctx.body = 'pets: ' + names.join(', ');\n  },\n\n  show: (ctx, name) =\u003e {\n    const pet = db[name];\n    if (!pet) return ctx.throw('cannot find that pet', 404);\n    ctx.body = pet.name + ' is a ' + pet.species;\n  }\n};\n\napp.use(_.get('/pets', pets.list));\napp.use(_.get('/pets/:name', pets.show));\n\napp.listen(3000, (err) =\u003e {\n  if (err) console.error(err.stack);\n  else console.log('listening on port 3000');\n});\n```\n\n## License\n\n  MIT\n","funding_links":[],"categories":["Middleware","仓库"],"sub_categories":["中间件"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoajs%2Froute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoajs%2Froute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoajs%2Froute/lists"}