{"_id":"koa-connect","_rev":"395769","name":"koa-connect","description":"Use Connect/Express middleware in Koa","dist-tags":{"latest":"2.1.0"},"maintainers":[{"name":"lourd","email":"louis@grovelabs.io"},{"name":"vkurchatkin","email":"vladimir.kurchatkin@gmail.com"}],"time":{"modified":"2021-08-04T04:11:13.000Z","created":"2014-08-19T16:02:19.354Z","2.1.0":"2020-06-26T19:51:06.374Z","2.0.1":"2018-02-14T16:36:12.268Z","2.0.0":"2017-01-12T16:22:16.334Z","1.0.0":"2014-08-19T16:02:19.354Z"},"users":{"shanewholloway":true},"author":{"name":"Vladimir Kurchatkin","email":"vladimir.kurchatkin@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/vkurchatkin/koa-connect.git"},"versions":{"2.1.0":{"name":"koa-connect","version":"2.1.0","description":"Use Connect/Express middleware in Koa","repository":{"type":"git","url":"git+https://github.com/vkurchatkin/koa-connect.git"},"main":"index.js","types":"index.d.ts","author":{"name":"Vladimir Kurchatkin","email":"vladimir.kurchatkin@gmail.com"},"contributors":[{"name":"Louis DeScioli","url":"https://descioli.design"}],"license":"MIT","scripts":{"start":"tsc --watch","build":"tsc -p tsconfig-build.json","test":"mocha -r ts-node/register tests.ts","test:watch":"npm run test -- --watch --watch-extensions ts --reporter nyan"},"devDependencies":{"@types/body-parser":"^1.19.0","@types/koa":"^2.0.46","@types/mocha":"^7.0.2","@types/node":"^10.9.2","@types/supertest":"^2.0.9","body-parser":"^1.19.0","husky":"^4.2.5","koa":"^2.0.0","lint-staged":"^10.2.9","mocha":"^2.3.4","prettier":"^2.0.5","supertest":"^1.1.0","ts-node":"^8.10.2","typescript":"^3.0.1"},"keywords":["koa","connect","express","middleware"],"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"!(*.d).ts":"prettier --single-quote --write","*.md":"prettier --write"},"gitHead":"3f7c4020604895f6693c622fd0b48b377005f5da","bugs":{"url":"https://github.com/vkurchatkin/koa-connect/issues"},"homepage":"https://github.com/vkurchatkin/koa-connect#readme","_id":"koa-connect@2.1.0","_nodeVersion":"10.16.3","_npmVersion":"6.13.7","dist":{"shasum":"16bce0a917c4cb24233aaac83fbc5b83804b4a1c","size":5374,"noattachment":false,"key":"/koa-connect/-/koa-connect-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/koa-connect/download/koa-connect-2.1.0.tgz"},"maintainers":[{"name":"lourd","email":"louis@grovelabs.io"},{"name":"vkurchatkin","email":"vladimir.kurchatkin@gmail.com"}],"_npmUser":{"name":"lourd","email":"louis.descioli@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-connect_2.1.0_1593201066165_0.13624625029081217"},"_hasShrinkwrap":false,"publish_time":1593201066374,"_cnpm_publish_time":1593201066374},"2.0.1":{"name":"koa-connect","version":"2.0.1","description":"Use Connect/Express middleware in Koa","repository":{"type":"git","url":"git+https://github.com/vkurchatkin/koa-connect.git"},"main":"index.js","author":{"name":"Vladimir Kurchatkin","email":"vladimir.kurchatkin@gmail.com"},"contributors":[{"name":"Louis DeScioli","url":"https://descioli.design"}],"license":"MIT","scripts":{"test":"mocha tests.js","test:watch":"npm run test -- --watch --reporter nyan"},"devDependencies":{"koa":"^2.0.0","mocha":"^2.3.4","supertest":"^1.1.0"},"keywords":["koa","connect","express","middleware"],"gitHead":"3956c5f694839d00064ab9c5ad876ccc6cd268fb","bugs":{"url":"https://github.com/vkurchatkin/koa-connect/issues"},"homepage":"https://github.com/vkurchatkin/koa-connect#readme","_id":"koa-connect@2.0.1","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"lourd","email":"louis.descioli@gmail.com"},"dist":{"shasum":"2acad159c33862de1d73aa4562a48de13f137c0f","size":8052,"noattachment":false,"key":"/koa-connect/-/koa-connect-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/koa-connect/download/koa-connect-2.0.1.tgz"},"maintainers":[{"name":"lourd","email":"louis@grovelabs.io"},{"name":"vkurchatkin","email":"vladimir.kurchatkin@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-connect_2.0.1_1518626171470_0.7200071970310564"},"_hasShrinkwrap":false,"publish_time":1518626172268,"_cnpm_publish_time":1518626172268},"2.0.0":{"name":"koa-connect","version":"2.0.0","description":"Use Connect/Express middleware in Koa","repository":{"type":"git","url":"git+https://github.com/vkurchatkin/koa-connect.git"},"main":"index.js","author":{"name":"Vladimir Kurchatkin","email":"vladimir.kurchatkin@gmail.com"},"contributors":[{"name":"Louis DeScioli","email":"louis.descioli@gmail.com"}],"license":"MIT","scripts":{"test":"mocha tests.js","test:watch":"npm run test -- --watch --reporter nyan"},"devDependencies":{"koa":"^2.0.0","mocha":"^2.3.4","supertest":"^1.1.0"},"keywords":["koa","connect","express","middleware"],"gitHead":"43e59d484a311fa3ecb4dce5f4c8edf487ecd5f9","bugs":{"url":"https://github.com/vkurchatkin/koa-connect/issues"},"homepage":"https://github.com/vkurchatkin/koa-connect#readme","_id":"koa-connect@2.0.0","_shasum":"b69da158fe5df04a59f5fce57b147343f6ff652e","_from":".","_npmVersion":"4.0.5","_nodeVersion":"7.4.0","_npmUser":{"name":"lourd","email":"louis@grovelabs.io"},"dist":{"shasum":"b69da158fe5df04a59f5fce57b147343f6ff652e","size":3370,"noattachment":false,"key":"/koa-connect/-/koa-connect-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/koa-connect/download/koa-connect-2.0.0.tgz"},"maintainers":[{"name":"lourd","email":"louis@grovelabs.io"},{"name":"vkurchatkin","email":"vladimir.kurchatkin@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/koa-connect-2.0.0.tgz_1484238134410_0.5455546798184514"},"directories":{},"publish_time":1484238136334,"_cnpm_publish_time":1484238136334,"_hasShrinkwrap":false},"1.0.0":{"name":"koa-connect","version":"1.0.0","description":"Use connect and express middleware in koa","main":"index.js","author":{"name":"Vladimir Kurchatkin","email":"vladimir.kurchatkin@gmail.com"},"respository":"vkurchatkin/koa-connect","license":"MIT","devDependencies":{"koa":"^0.10.0"},"dependencies":{"connect":"^2.25.7"},"_id":"koa-connect@1.0.0","_shasum":"0aecf10df15f32526ad15815115cb3d40aece705","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"vkurchatkin","email":"vladimir.kurchatkin@gmail.com"},"maintainers":[{"name":"lourd","email":"louis@grovelabs.io"},{"name":"vkurchatkin","email":"vladimir.kurchatkin@gmail.com"}],"dist":{"shasum":"0aecf10df15f32526ad15815115cb3d40aece705","size":1067,"noattachment":false,"key":"/koa-connect/-/koa-connect-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/koa-connect/download/koa-connect-1.0.0.tgz"},"directories":{},"publish_time":1408464139354,"_cnpm_publish_time":1408464139354,"_hasShrinkwrap":false}},"readme":"# koa-connect [![npm package badge][npm badge]][npm]\n\n[npm badge]: https://badge.fury.io/js/koa-connect.svg\n[npm]: https://www.npmjs.com/package/koa-connect\n\nUse [Express](https://github.com/strongloop/express)/[Connect](https://github.com/senchalabs/connect) middleware with [Koa](https://github.com/koajs/koa).\n\n## Warning\n\nIt is **highly** recommended to use a Koa-specific middleware instead of trying to convert an Express version when they're available. There is a non-trivial difference in the Koa and Express designs and you will inevitably run into some issues. This module is a workaround for the specific cases where the differences can be ignored. Additionally, it also enables library authors to write 1 version of their HTTP middleware.\n\n### Always use `next` middleware parameter\n\nExpress middlewares need to declare and invoke the `next` callback appropriately for the koa-connect integration to work correctly.\n\n### For library authors\n\nIf you're attempting to write a framework-agnostic middleware library, be sure to use only core HTTP methods and not any Express-dependent APIs like `res.send`.\n\n## Installation\n\n```sh\nnpm install koa-connect\n```\n\n## Usage\n\nSee [`examples/`](./examples) for more practical usage.\n\n```javascript\nconst Koa = require('koa');\nconst c2k = require('koa-connect');\n\n// A generic Express-style middleware function\nfunction connectMiddlware(req, res, next) {\n  res.writeHead(200, { 'Content-Type': 'text/plain' });\n  res.end('From the Connect middleware');\n  next();\n}\n\n// A generic Koa middlware, without async/await\nfunction koaMiddlware(ctx, next) {\n  next()\n    .then(() => {\n      // The control flow will bubble back to here, like usual\n    })\n    .catch((err) => {\n      // Error handling from downstream middleware, like usual\n    });\n}\n\n// A generic Koa middlware with async/await\nasync function koaMiddleware(ctx, next) {\n  try {\n    await next();\n  } catch (e) {\n    // Normal error handling\n  }\n  // Normal control flow\n}\n\nconst app = new Koa();\napp.use(koaMiddlware);\napp.use(c2k(connectMiddlware));\napp.use((ctx, next) => {\n  console.log('It will continue on to here');\n});\n\napp.listen(3000);\n```\n\n## Contributing\n\n### Developing\n\n`npm start` starts the TypeScript compiler in watch mode. Code will be auto-formatted upon commit as part of the Prettier + lint-staged + Husky setup.\n\n### Building\n\n`npm run build` produces the types declaration file and JavaScript file for publishing.\n\n### Testing\n\n`npm test` runs the tests. Tests are in `tests.js` and are made with the [Mocha](https://mochajs.org) framework.\n\nUse `npm run test:watch` in conjunction with `npm start` to automatically re-run the tests when the source changes.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/vkurchatkin/koa-connect#readme","bugs":{"url":"https://github.com/vkurchatkin/koa-connect/issues"},"license":"MIT"}