{"_id":"@azure-functions-middlewares/core","_rev":"4-b748096571c9b57700cc3abac8971314","name":"@azure-functions-middlewares/core","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@azure-functions-middlewares/core","version":"1.0.0","description":"The most complete middleware solution for ⚡ Azure Functions.","main":"src/index.js","scripts":{"test":"mocha tests/** --timeout 5000"},"repository":{"type":"git","url":"git+https://github.com/NOALVO/azure-functions-middlewares.git"},"keywords":["azure-functions","middleware","middlewares","middleware-pipeline"],"author":{"name":"Gustavo Gondim","email":"gustavo@midianoalvo.com.br","url":"https://github.com/NOALVO"},"license":"MIT","bugs":{"url":"https://github.com/NOALVO/azure-functions-middlewares/issues"},"homepage":"https://github.com/NOALVO/azure-functions-middlewares#readme","_id":"@azure-functions-middlewares/core@1.0.0","_nodeVersion":"10.16.3","_npmVersion":"6.11.3","dist":{"integrity":"sha512-0FNoa2P/YI73EoC5XfH/vMf7QRVLNHwtkZNrzI2QbiFbUw/k7f+JfjWPb6/E8e9JKzZ62tFmukBxMw/mec84Cg==","shasum":"96c1d4a95131b6d6c18b1f93bc0fbcc8e696c41c","tarball":"https://registry.npmjs.org/@azure-functions-middlewares/core/-/core-1.0.0.tgz","fileCount":3,"unpackedSize":8694,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdis9sCRA9TVsSAnZWagAAnNgP/3ugqlYDWASQYrqwLYvA\njlJfEyxT0aesdkrIFDSKQuHwP1Llw49iJk/zeWKmEhQoew3I3II4HsfXCeRs\nkDXOp0WVfAM/PejWeSF3i+qTnJ8OL0uPB+8v18Hj7nYKR2gH1VVGlt0Z3GhF\nu6tiKKcskpx/ONK7G0AJbWMvhV8YiYt94OSNiZsfCfqAxLZzwkNy63II62Vl\n1veqOsxanNUKW5TjV23GId7BXs4o4B9Ip5jhba50FoPWlWhrItT7InQuXkr9\nRXOOaE/ILmJMkTXCYhLexPAtJvmX/mtdju0h+Kw+sT0KEA2xZwThwVWqWH0c\nr49s+UR8qGsWnBLf3sBMjQl/94qZYxkmIg1rSUpiLevd7MB85YdtXPIAFl+y\nRkUQkTOuN4r4T7Lwf+pwx2cIRY3NYLbv47rUKKG6fFrlBCQ5p9Lxq3X9HmFI\n2U99eAqDEh+IvzbbKWv/GVWUQv1uhSjV22X27GOOw54dL+G7jC1iCswTJ0s5\nOmk+ySol9NnjUPn1bAiZPcJYpZc8gnDYADIXQMgGX4fWDEnUtZ6Tk+o2bYCr\nyoKBR2moTK57c2Hdxdw6cGRD/d7mNRylMfoGP6eGiOCpk1zHE5lA1CtfTvB8\nGovSO8jl5lrJor/uwN3AY6oAZobfHujD6PUVzrrVGuFqLjSuSFbD9SSkPiCg\npTvo\r\n=lDxa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHF4VsGKOXd5BprFViKSPD60UgeTtU8V2D2zIqCn4KkqAiBS9S2kJiDN/v2/w1r8QEd5G4B29aCtZUHpGkrtbPD2mA=="}]},"maintainers":[{"name":"ggondim","email":"gustavospgondim@gmail.com"}],"_npmUser":{"name":"ggondim","email":"gustavospgondim@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/core_1.0.0_1569378155733_0.7533876550665914"},"_hasShrinkwrap":false},"1.0.1":{"name":"@azure-functions-middlewares/core","version":"1.0.1","description":"The most complete middleware solution for ⚡ Azure Functions.","main":"src/index.js","scripts":{"test":"mocha tests/** --timeout 5000"},"repository":{"type":"git","url":"git+https://github.com/NOALVO/azure-functions-middlewares.git"},"keywords":["azure-functions","middleware","middlewares","middleware-pipeline"],"author":{"name":"Gustavo Gondim","email":"gustavo@midianoalvo.com.br","url":"https://github.com/NOALVO"},"license":"MIT","bugs":{"url":"https://github.com/NOALVO/azure-functions-middlewares/issues"},"homepage":"https://github.com/NOALVO/azure-functions-middlewares#readme","_id":"@azure-functions-middlewares/core@1.0.1","_nodeVersion":"10.16.3","_npmVersion":"6.11.3","dist":{"integrity":"sha512-Df0lQax8Y/yq+KVa2WKkWjozy9L0wnYfW2hpj2sneS67MLpnU+kX0DCrkljIh38HFoaRnu7TJgH3o9B9D6de1g==","shasum":"f3fb8af9137a4503c8e12ccbdc8dbb9e115c4b17","tarball":"https://registry.npmjs.org/@azure-functions-middlewares/core/-/core-1.0.1.tgz","fileCount":3,"unpackedSize":8814,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdklDlCRA9TVsSAnZWagAArD4P/2cQxseY6YuSQUyedD7o\naQPmMo7jWm1dEdUGY4Ou2U+a/2q0WtGe6zKkCS2P0XZ9Do8nKjGUR0pqf6db\nFAgdzoHofYzvrpHy6fPC/sUdWGGInx2j8SckZftHQij9to+YrPqbtjt/6OWG\nmwHZEywMz39bm4rxknUq+RpyHh6S1tcGd1Ktkns7ctKbf3PUbD3Yv59GAzxU\no8Mot/gkncasjxsuFAs4XW0+oK8J/v/NtOrUhdal5oZTmH3RYypc+lSt4Bim\nZ7B9jq7GBEmijsRdgBCVO9as7Hi/xn7R2Cq4IzCWiyOnRfqJmzmkk4qv1fFa\niHxvhZ7lWWjWBV4UhpPJg0yAgRWs3AcEytbb0EdQHiycNFl6HsSx3xrU/Rl0\nimkD0wDKrrk98B8UP5AQLZzTPQvGpD5+NRGEc8cqolkmLaVMPycIW6vG/yju\nWr6uJo5NCov1cisyi85FvnLwpKzNG36fIJohttnklmLCWqb6AgmGZ+Y1LRBL\nfG6GLwWgeTiEZjRnvW74YyLTO5mhm2U8kfyUT8zjlsl9hKI5IgjWuhngwCrl\nZ2pJSayZ6OMztlB48dB9znio3E8+rZiQCoX31+B6DR06eSAIgCCv6uyhTVyC\nDIPRmfbWexJqL4ccjkshakUaM2n/aWlCZJyVcrFshZsMMh+3OzzhfCNZvb5Y\nGxs1\r\n=X8TS\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCyJfVfIsh8rn1GhzsAZ0pihAF2w6PgDnLg/jDPw0cMuwIhAN60lIGf6FCF5CqZRojamy+dPgudG0ABTA3sqSGk4Wik"}]},"maintainers":[{"email":"felipe.negri43@gmail.com","name":"felipe-negri"},{"email":"gustavospgondim@gmail.com","name":"ggondim"}],"_npmUser":{"name":"ggondim","email":"gustavospgondim@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/core_1.0.1_1569870052969_0.5044936815795713"},"_hasShrinkwrap":false},"1.1.0":{"name":"@azure-functions-middlewares/core","version":"1.1.0","description":"The most complete middleware solution for ⚡ Azure Functions.","main":"src/index.js","scripts":{"test":"mocha tests/** --timeout 5000"},"repository":{"type":"git","url":"git+https://github.com/NOALVO/azure-functions-middlewares.git"},"keywords":["azure-functions","middleware","middlewares","middleware-pipeline"],"author":{"name":"Gustavo Gondim","email":"gustavo@midianoalvo.com.br","url":"https://github.com/NOALVO"},"license":"MIT","bugs":{"url":"https://github.com/NOALVO/azure-functions-middlewares/issues"},"homepage":"https://github.com/NOALVO/azure-functions-middlewares#readme","_id":"@azure-functions-middlewares/core@1.1.0","_nodeVersion":"12.16.3","_npmVersion":"6.14.5","dist":{"integrity":"sha512-GaaSK3hMFu9wYk/zPLe8DP4kMw39L3BRsRQiOoVM8Bgj8HelIk0ojXFGUfZC2av1ajmoSJtl1AlG+FjZtxrJXA==","shasum":"f162e9e057f8da83a5835e1896f1bba89905eed8","tarball":"https://registry.npmjs.org/@azure-functions-middlewares/core/-/core-1.1.0.tgz","fileCount":3,"unpackedSize":8925,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe3cWJCRA9TVsSAnZWagAASY4P/0aBg+lBlOBkphYNvjCX\n1QbiWlxvtNADaCJELfpB9oSiAsCUZT28rYzW2q1KBTUUXHez7Ddmag556ZQA\nL4Bmki0wCLoo9kZo2emgeFIoXzqGo2zuC6Zq/xiqM1r8dQ0DPPUQPtUBpax5\nLH+N2+RTwYglb+ge6ym/zQzVoDSgAgW62ILb4EPzNLsmBcM/UTuRFebLGqy9\nUqnTpGQIm9RYY9+4Vzg7hYv1cDOX6GBuJXRm7EPOxSwd8haWaUF3tLNLspnn\nzAChNw8+tYM43tecr26NaKODRQTrvnIHJYelnoehk46UFE+65LSVqts/kOyV\n3S15EG9Q8FWiJhYXL1LP9jFk/FX5H3IP/UNds/qzrXJ3ThKX3pin+a+/hDTt\nuYpJCsRPZgpzdZtvO0N94iiK70QBFCiwPIX+98owxcIpJmUOMhmmd06AWlL0\nksyGBrapRbL8MZNvmUo4j5lmp2h5zkLRFcIFzR/gvOohFWOOHwsoyKjGYSw2\nAjOelIDcpVkyxpdMdaiWRcGiA4PKuwip3q0uRcWRpw+jx59mBMJYNhmEQCR9\nb5CjkJFdNqVbTg1jufA4qtCVAop+oRg3IGHOc2EKXB2feI1OIN+NaxfmQzeY\n2YzWzvfM+dwAoaWvtZZ7e8CbmazHXrdD6/SIl0pHw8ex9wr1WUWKce11XJAS\nirSM\r\n=pn9A\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDR+E1JR7lzoSI/8SgyKB/FdQPiJ/4l9oZBIad6PCkW6AIgBuKMpDx2KqsYGdmxMWnpl8/uyhhh+qoeh4f1O91+4vQ="}]},"maintainers":[{"email":"felipe.negri43@gmail.com","name":"felipe-negri"},{"email":"gustavospgondim@gmail.com","name":"ggondim"}],"_npmUser":{"name":"ggondim","email":"gustavospgondim@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/core_1.1.0_1591592329152_0.9407988304904018"},"_hasShrinkwrap":false}},"time":{"created":"2019-09-25T02:22:35.504Z","1.0.0":"2019-09-25T02:22:35.963Z","modified":"2022-04-04T17:17:20.688Z","1.0.1":"2019-09-30T19:00:53.152Z","1.1.0":"2020-06-08T04:58:49.263Z"},"maintainers":[{"email":"felipe.negri43@gmail.com","name":"felipe-negri"},{"email":"gustavospgondim@gmail.com","name":"ggondim"}],"description":"The most complete middleware solution for ⚡ Azure Functions.","homepage":"https://github.com/NOALVO/azure-functions-middlewares#readme","keywords":["azure-functions","middleware","middlewares","middleware-pipeline"],"repository":{"type":"git","url":"git+https://github.com/NOALVO/azure-functions-middlewares.git"},"author":{"name":"Gustavo Gondim","email":"gustavo@midianoalvo.com.br","url":"https://github.com/NOALVO"},"bugs":{"url":"https://github.com/NOALVO/azure-functions-middlewares/issues"},"license":"MIT","readme":"# azure-functions-middlewares\nThe most complete middleware solution for ⚡ Azure Functions.\n\n![npm bundle size](https://img.shields.io/bundlephobia/min/@azure-functions-middlewares/core?label=package%20size)\n![npm](https://img.shields.io/npm/dw/@azure-functions-middlewares/core)\n![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/@azure-functions-middlewares/core)\n\n## Features\n- Async/await middleware support\n- [Cascade error capture](#Capturing-errors) (a.k.a. \"catch middleware\")\n- `New!` [Execution order customization](#Customizing-execution-order) (in three phases)\n- `New!` [Conditional middlewares](#Conditional-middlewares)\n- `New!` [Middleware execution prevention](#Stoping-the-cascade-execution) (a.k.a. \"stop signal\")\n\n## How to use\n\n### Simplest usage\n\nInstall latest core version at NPM ![npm](https://img.shields.io/npm/v/@azure-functions-middlewares/core)\n\n```\n$ npm install --save @azure-functions-middlewares/core\n```\nListen to the cascade exporting it as the function entry point:\n\n```javascript\nconst FunctionCascade = require('@azure-functions-middlewares/core');\n\nmodule.exports = new FunctionCascade()\n  .use(async (context) => {\n    context.res.body = { message: 'My first middleware!' };\n  })\n  .listen();\n```\n\n**Tips!**\n- Always call `listen()` at the end of cascade\n- Always use async functions as middlewares. This cascade module doesn't supports sync functions anymore, we are at 21th century.\n- Do not return anything inside your middleware function, unless you want to [throw an error](#capturing-errors). Always use `context.res` to output what you need.\n\n### Capturing errors\n\nErrors thrown or anything returned by a middleware will stop the cascade execution and will call cascade's `catchFunction`.\n\nA default `catchFunction` is set to log the error at Azure Function's context and to return a HTTP 500 status.\n\nIf you want to catch function, use the `catch()` method:\n\n```javascript\nconst FunctionCascade = require('@azure-functions-middlewares/core');\nconst app = new FunctionCascade();\n\n// app.use(...); // middlewares\n\napp.catch((context, error) => {\n  context.res.status = 404;\n  context.res.headers['X-Message'] = error;\n});\n\nmodule.exports = app.listen();\n```\n\n### Customizing execution order\n\nThis module executes the middleware cascade in three phases. You can customize the execution phase of your middleware by passing a `phase` argument to `use()` or `useIf()` methods:\n\n```javascript\napp.use((context) => {\n  context.log('This will be executed at the last phase');\n}, app.Phases.POST_PROCESSING);\n\napp.use((context) => {\n  context.log('This will be executed at the first phase');\n}, app.Phases.PRE_PROCESSING);\n\napp.use((context) => {\n  context.log('This will be executed at the second phase');\n});\n```\n\nPhases constants to use as phase argument are exposed into cascade's property `Phases`:\n\n```\napp.Phases.PRE_PROCESSING => first phase\napp.Phases.MAIN => second phase\napp.Phases.POST_PROCESSING => last phase\n```\n\n### Conditional middlewares\n\nYou can conditionally execute a middleware by passing an evaluation function to the `useIf` method.\n\nExample:\n\n```javascript\nconst isPostRequest = (context) => context.req.method === 'POST';\n\napp.useIf(isPostRequest, (context) => {\n  context.log('This will be executed only if is a HTTP POST');\n});\n```\n\n### Stoping the cascade execution\n\nYou can stop the cascade execution at any time by returning the second middleware argument, `STOP_SIGNAL`.\n\nExample:\n\n```javascript\napp.useIf((context, STOP_SIGNAL) => {\n  if (!req.query.access_token) {\n    context.res.status = 401;\n\n    return STOP_SIGNAL;\n  }\n});\n```\n\n## License\n\n![GitHub](https://img.shields.io/github/license/noalvo/azure-functions-middlewares)\n","readmeFilename":"README.md"}