{"name":"koa-router","description":"Router middleware for koa. Provides RESTful resource routing.","author":{"name":"Alex Mingoia","email":"talk@alexmingoia.com"},"repository":{"type":"git","url":"git+https://github.com/alexmingoia/koa-router.git"},"main":"lib/router.js","files":["lib"],"scripts":{"start":"yarn test --watch","test":"nyc --cache ava","coverage":"nyc report --reporter=html","lint":"eslint lib","docs":"jsdoc2md -f lib/**/*.js -t docs/templates/API.hbs > docs/API.md"},"version":"8.0.0-alpha.1","keywords":["koa","middleware","router","route"],"dependencies":{"debug":"^3.1.0","http-errors":"^1.3.1","koa-compose":"^4.0.0","methods":"^1.1.2","path-to-regexp":"1.7"},"devDependencies":{"ava":"^0.25.0","eslint":"^4.19.1","eslint-config-airbnb-base":"12.1.0","eslint-plugin-import":"2.10.0","jsdoc-to-markdown":"^4.0.1","koa":"^2.5.0","mocha":"^5.1.1","nyc":"^11.6.0","supertest":"^3.0.0"},"engines":{"node":">= 8"},"license":"MIT","ava":{"snapshotDir":"test/fixtures"},"readme":"# koa-router\n\n[![NPM version](https://img.shields.io/npm/v/koa-router.svg?style=flat)](https://npmjs.org/package/koa-router)\n[![NPM Downloads](https://img.shields.io/npm/dm/koa-router.svg?style=flat)](https://npmjs.org/package/koa-router)\n[![Node.js Version](https://img.shields.io/node/v/koa-router.svg?style=flat)](http://nodejs.org/download/)\n[![Build Status](https://img.shields.io/travis/alexmingoia/koa-router.svg?style=flat)](http://travis-ci.org/alexmingoia/koa-router)\n[![Gitter Chat](https://img.shields.io/badge/gitter-join%20chat-1dce73.svg?style=flat)](https://gitter.im/alexmingoia/koa-router/)\n\nExpress-like HTTP routing for [koa](https://github.com/koajs/koa)\n\n[API Documentation](docs/api.md)\n\n[Examples and Other Documentation](docs/)\n\n[Changelog](CHANGELOG.md)\n\n[UPGRADING.md](UPGRADING.md)\n\n## Installation\n\n`koa-router` **requires node 8** or above.\n\n```sh\nnpm install -S koa-router\n```\n\n## Hello World\n\n```js\nconst app = new Koa();\nconst router = new Router();\n\nrouter.get('/hello', async (ctx) => {\n  ctx.body = 'world';\n});\n\napp.use(router.routes());\napp.listen(3000);\n```\n\n## Features\n\n* Express-style routing using `router.get`, `router.put`, `router.post`, etc\n\n```js\nconst router = new Router();\n\nrouter.patch('/users/:id', (ctx) => ...);\nrouter.get('/users', (ctx) => ...);\n```\n\n* Named URL parameters (`/users/:id` -> `ctx.params.id`)\n\n```js\nconst router = new Router();\n\nrouter.get('/articles/:category', (ctx) => {\n  // ctx.params.category available\n});\n```\n\n* Named routes with URL/path generation\n\n```js\nconst router = new Router();\n\nrouter.get('article', '/article/:id', (ctx) => ...);\nrouter.path('article', 3);\n// => /articles/3\n```\n\n* Nest, prefix routers recursively\n\n```js\nconst rootRouter = new Router();\nconst authorRouter = new Router();\nconst bookRouter = new Router();\n\nbookRouter.get('/', (ctx) => ...);\nauthorRouter.get('/:id', (ctx) => ...);\n\nauthorRouter.nest('/:id/books', bookRouter);\nrootRouter.nest('/books', bookRouter);\nrootRouter.nest('/authors', authorRouter);\n\nrootRouter.routes();\n// =>\n// /books\n// /authors/:id\n// /authors/:id/books\n\n```\n\n* async/await support\n\n```js\nconst router = new Router();\n\nrouter.get('/users/:id', async (ctx) => {\n  ctx.state.user = await User.find(ctx.params.id);\n});\n```\n\n* Responds to `OPTIONS` requests with allowed methods\n* Support for `405 Method Not Allowed` and `501 Not Implemented` handlers\n* Robust matching engine: [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp)\n\n_Koa Router version 7 and 8 are only compatible with koa 2 and do not work with koa 1 or any other koa 1 middlewares_\n\n## Upgrading from 7.x to 8.x\n\nSee the [UPGRADING.md](./UPGRADING.md)\n\n## Contributing\n\nPlease submit all issues and pull requests to the [alexmingoia/koa-router](http://github.com/alexmingoia/koa-router) repository!\n\nGenerate coverage reports with `npm run coverage`\n\nGenerate the docs with `npm run docs`\n\nRun the linter with `npm lint`\n\n## Tests\n\nRun tests using `npm test`\n\n## Support\n\nIf you identify an issue with this software or have a suggestion, please open an issue [here](https://github.com/alexmingoia/koa-router/issues).\n\n## License\n\n[MIT](LICENSE.md)\n","readmeFilename":"README.md","gitHead":"c0e9e088cd679f3c4030b73d8c0fc7b69e1ffecb","bugs":{"url":"https://github.com/alexmingoia/koa-router/issues"},"homepage":"https://github.com/alexmingoia/koa-router#readme","_id":"koa-router@8.0.0-alpha.1","_npmVersion":"5.6.0","_nodeVersion":"9.4.0","_npmUser":{"name":"jbielick","email":"jbielick@gmail.com"},"dist":{"integrity":"sha512-0q2QRAVEpBfL8UbRSFWVZhiKzE2MYvLyVruhrXcpywRmXfzeGxl0GYEyo+FJedPjGfwjiQHqWdRHTMb2uIx7yQ==","shasum":"ce082d77319274224e742d99f7cb6869a8c3c0c9","tarball":"http://registry-npm.ywwl.com/koa-router/download/koa-router-8.0.0-alpha.1.tgz","fileCount":7,"unpackedSize":47412,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa5KFhCRA9TVsSAnZWagAARtEP/i/TwvmBlnzVGeXpN9UM\nx52+wGMlv97i1xC8VdH6NnrQC+uo100mk8dda01EKe2xqKbsUtoArVZ1rxuN\n94ls7LB28QSOI07SY4Bll2Cj2NtVySMVywGBr3zJbCCj2zn8BJU21uaJLjVc\nDxmFwxcdrloORk/trlMS6HkikCHozaUGZUwORn4Dwqf2d5T6fbpro2N6AVZ9\nLvmWbb69kqG0bmwjpaH/c5eZFUHhTmH5/JTWYhVywxOPY6P/sGuupK8xNe/1\nI8e6GAifLkZi+deQQMM3I1zaVN3dDmNlJyivyJfEMpVe95+T2y1/r8B2UEt+\no6qbgMIXG7iSZD2QBuJmNRCreBu+utMs6E/QfLWZZmEAQ9fvA1uZjmdHPX7C\nOWFSWWore2BaiB1QEYVTLzu9E3HOapeWkOSlzqpUJL6CpvgXATCN9VhvVN3D\n8Zfa3Rccb8P9gnShWuL3KbHiw0bN8d/eufHPZRaYVOIBHA7F9sDEtcwmzkCj\n1r8ULus65i8Njek+WNwhbt1Ws2AxTPY6Al107DH5zRQJD1vuaqMaYT2zzg6o\ngdo1IGvnPuuXAdBIcXBRsimcbh+ECO5ir1SHrmf2X1g72Ov+j0vGETk1j/T0\ngY0i2/bTahlyWLR1bG0f8GkXPcaIG6yAyntmcZHx2jhtNai1UcjQIH+dR4YE\n9dFy\r\n=Bhs9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEPgxYkVRU1keU/dmMDqNaWKhgEBc2Jp9OFBV/ynQmoQAiB66f8A6qGSM9SBD9dm4odB2nmycYKB995D36Vl5Yhs7A=="}],"size":13793,"noattachment":false,"key":"/koa-router/-/koa-router-8.0.0-alpha.1.tgz"},"maintainers":[{"name":"amingoia","email":"talk@alexmingoia.com"},{"name":"jbielick","email":"jbielick@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-router_8.0.0-alpha.1_1524932960459_0.16873989178516435"},"_hasShrinkwrap":false,"deprecated":"Please use @koa/router instead, starting from v9! ","publish_time":1524932960534,"_cnpm_publish_time":1524932960534,"dist-tags":{"latest":"14.0.0","next":"8.0.0-alpha.1"}}