{"_id":"@art-of-coding/compose","_rev":"1-67d27f08b5526bbed5e97a504714ea18","name":"@art-of-coding/compose","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@art-of-coding/compose","version":"1.0.0","description":"A small middleware composer that uses async/await","main":"./dist/index.js","author":{"name":"Michiel van der Velde","email":"michiel@michielvdvelde.nl"},"homepage":"https://github.com/Art-of-Coding/compose","repository":{"type":"git","url":"git+https://github.com/Art-of-Coding/compose.git"},"engines":{"node":">=7.6.0"},"keywords":["middleware","async","await","compose"],"license":"MIT","devDependencies":{"typescript":"^4.1.5"},"bugs":{"url":"https://github.com/Art-of-Coding/compose/issues"},"_id":"@art-of-coding/compose@1.0.0","_nodeVersion":"14.8.0","_npmVersion":"6.14.7","dist":{"integrity":"sha512-UuqDlCSgMZT6jbjSyVoTF0ldC8Dn1RRVHSbHV4JmcTPMPymZeLtXf/ixkwCdOL+WgYru7NqXdP9AlCMKYM+TaA==","shasum":"86d40a303af1b99f073ef6f4fc630fbeed7526ec","tarball":"https://registry.npmjs.org/@art-of-coding/compose/-/compose-1.0.0.tgz","fileCount":5,"unpackedSize":4045,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgM7+TCRA9TVsSAnZWagAAlvYP/0bDfc6wJv+lsYZlK6EH\nxYI3TViT36DxmEGMXCZ6k2BvidZEW9b9x58jgiTMurdAPKHVQfjiCgCR98hV\nqa9NMoqXtuRRDJu/UZyBXTjS/4Lplau/Z0VKW0HA1HKelHI+5Z68kPl5U6XA\nspskeRp8PkNwAHaHPBs9QFN64dgTb2mZO1Y/ai8AdxmBNtgc5JB9ECc2Ziep\nLIretJni9CjILk37llvCIwbJUVWdBPhEkrzgIoylHmHx9tltLtidErmoy9hv\nf4jCYO7ulOzXztkIF4iyLvtfwp/FP4p50Y4DwoPYgK7U2Ixp5NRVolkLeGN/\ntDmcFng1U6kHzIfaX0gFlmTl37qoDkftr1il3WWSXqIYlu7cFLyN8fifbZ4M\nEKvrSX25U6qdju+bzZOFYIm1cAV+haSopLQ7K+tF2wR7LzQYrgGKdw694Wiz\nuDFaBYQhpuJzcNpkJMjWb+ZC4+XgaM6cyzrGhe7p88CFdrIHZze9kTfWwbPd\nJ1veU3GJZs1qlKzkewJiTQMcaX+3ugpuYrOlzhYo478A39HIhpzxo8iwlTA1\nb6cdSTLtVKlZclQ3wJTiBOVFlUYxGxdMZuvxVB0rs3tPQCsN+S1LkJPJZxzV\nxWJi/jAOEEL6La1Hz1ftFugY2AAuun+XXXIRkXZI2jQ/nTdUHDXPReoRx85U\nhLhD\r\n=GdD6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDletnvL+WWgec5+X78II68ttixkUFEg+B0rKGqoWBYjgIgGKpzIoUdWNhZL2zFLJkHz54jrna1bsEYaXhZxYddvK0="}]},"_npmUser":{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"},"directories":{},"maintainers":[{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/compose_1.0.0_1614004114664_0.49517728815286044"},"_hasShrinkwrap":false}},"time":{"created":"2021-02-22T14:28:34.541Z","1.0.0":"2021-02-22T14:28:34.818Z","modified":"2022-04-04T15:35:53.143Z"},"maintainers":[{"name":"michielvdvelde","email":"michiel@michielvdvelde.nl"}],"description":"A small middleware composer that uses async/await","homepage":"https://github.com/Art-of-Coding/compose","keywords":["middleware","async","await","compose"],"repository":{"type":"git","url":"git+https://github.com/Art-of-Coding/compose.git"},"author":{"name":"Michiel van der Velde","email":"michiel@michielvdvelde.nl"},"bugs":{"url":"https://github.com/Art-of-Coding/compose/issues"},"license":"MIT","readme":"# Compose\r\n\r\nSimple utility to compose multiple async/await middleware functions into a single\r\nmiddleware function.\r\n\r\nAlso see [@art-of-coding/lime](https://github.com/Art-of-Coding/lime).\r\n\r\n## Install\r\n\r\n```\r\nnpm i @art-of-coding/lime-compose\r\n```\r\n\r\n## API\r\n\r\n#### compose()\r\n\r\n```ts\r\ncompose<C = Context> (...middlewares: MiddlewareFunction<C>[]) => MiddlewareFunction<C>\r\n```\r\n\r\nComposes the middlewares into a single middleware function.\r\n\r\nTypeScript users can provide a context definition (`C`) which allows type checking\r\nwithin the middlewares. For more information about type checking see [index.ts](src/index.ts).\r\n\r\n## Example\r\n\r\n```ts\r\nimport compose, { Context } from '@art-of-coding/lime-compose'\r\n\r\n// Optional context definition\r\n// May extend `Context`, but this is not necessary\r\ninterface MyContext extends Context {\r\n  age?: number\r\n}\r\n\r\nconst composed = compose<MyContext>(\r\n  async (ctx, next) => {\r\n    // 1st middleware\r\n    ctx.age = 18\r\n    await next()\r\n  },\r\n  async (ctx, next) => {\r\n    // 2nd middleware\r\n    await next()\r\n  },\r\n  async ctx => {\r\n    // 3rd middleware\r\n  }\r\n)\r\n\r\nconst ctx = {}\r\ncomposed(ctx).then(() => {\r\n  // middleware completed\r\n}).catch(err => {\r\n  // middleware error\r\n})\r\n```\r\n\r\n### License\r\n\r\nCopyright 2019 [Michiel van der Velde](http://www.michielvdvelde.nl).\r\n\r\nThis software is licensed under the [MIT License](LICENSE).\r\n","readmeFilename":"README.md"}