{"_id":"@appconfiger/middy","name":"@appconfiger/middy","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.3":{"name":"@appconfiger/middy","version":"0.0.3","description":"Middy middleware for feature flag control based on AWS AppConfig","main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=16"},"scripts":{"build":"make build","build-module":"make build-module","unit-tests":"make unit-tests","lint":"make lint","lint-fix":"make lint-fix","publish-npm":"make publish","test":"make unit-tests","clean":"make clean"},"repository":{"type":"git","url":"git+https://github.com/flaviostutz/appconfiger.git"},"author":{"name":"flaviostutz"},"license":"MIT","bugs":{"url":"https://github.com/flaviostutz/appconfiger/issues"},"homepage":"https://github.com/flaviostutz/appconfiger#readme","devDependencies":{"@aws-sdk/client-appconfigdata":"^3.226.0","@shopify/eslint-plugin":"^42.0.1","@stutzlab/eslint-config":"^0.0.7","@types/aws-lambda":"^8.10.108","@types/diff":"^5.0.2","@types/jest":"^29.1.2","@types/node":"^18.11.0","@typescript-eslint/eslint-plugin":"^5.40.0","@typescript-eslint/parser":"^5.40.0","aws-sdk-client-mock":"^2.0.1","esbuild":"^0.16.8","esbuild-jest":"^0.5.0","eslint":"^8.25.0","eslint-config-prettier":"^8.5.0","jest":"^29.2.0","prettier":"2.7.1","typescript":"^4.8.4"},"dependencies":{"@appconfiger/core":"*","@middy/core":"^3.6.2","aws-lambda":"^1.0.7","aws-sdk":"^2.1253.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"licenseText":"MIT License\n\nCopyright (c) 2022 Flavio Stutz\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@appconfiger/middy@0.0.3","dist":{"shasum":"c697788ef3812b5c01a4c9578b98b485ded92cff","integrity":"sha512-z2uzjGazB/rH7odJioMej4hKbQI+o/fPHX43TM3pXjkIem6q5W1Ee35SQDH99LZceNZR485jkwcfKWxdQSDKBg==","tarball":"https://registry.npmjs.org/@appconfiger/middy/-/middy-0.0.3.tgz","fileCount":6,"unpackedSize":790916,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCknxuu2Lda8F4lQKA7qfqcR3xz7PoFJq4qWqC0xNh5rwIgduI8UoUhMhJoT+zk9wjtl08Pa6s3Jc2i8m+x+s7rrVY="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjn4BpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqsVRAAgLpW6A7JWCHq/sa1xrG3FlqE3zZ0CjJeZICXbgYWIUhv9eaj\r\nLxyKoWD7RDnNwdLUiDWD+Dn5jkwl3dd8cJITBav8Vo+kctyRcDV/NfELJYxR\r\nsPZeg9TWemxceZvw7vs/C1AXd+bH2R3x+GyK9kn1MoTsQjlfti8ApPbeMWhO\r\nU4fIVweKluM0y6JSx5Lv88hGhnW0s7sNlBHU+RH3BtoNxvEp25aj37k/sc7O\r\n07OR08Jpnsw+HpM7XUyouFclI0G9T+uwMTFLmLImqj9W54szfwqGYgRK+/6X\r\n0FTc7eeWgiGd7SLT/RIXCAufDyriV925tQrHt8mcfl3MmDTQ9tjHNPy3MngF\r\nkhybOjCPgXibuwuPMuHNTRT9qpcPrkTqeN3KKl73SkjAXU14IShF4yfetqoj\r\nMqEIVsr/GHkmZF6hUOObYmJmr4yWZQCqKeHl1Qbov2pHiCg9BLxkpXBxp441\r\npNbuh3a/VzEYEzZPxxIArHdlNSAFqlksfjdP2ItR/Z95QRr1noAk89jeB4K8\r\n8aTgr4eHRIXw7aME6D8oirDA7EMbOMsqxSskGIIq2rvKHzkHoPQyTklMJEK7\r\nTVqbtUo/sBGqF2q1IaZNXiyUO89vrDUExjkU0j5BDYmk3DWO0RGqoN1vGtNx\r\nJVCQrnD7DXwQ32FXtRkbn29rJtWMtgyHkQE=\r\n=2IA7\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"flaviostutz","email":"flaviostutz@gmail.com"},"directories":{},"maintainers":[{"name":"flaviostutz","email":"flaviostutz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/middy_0.0.3_1671397481751_0.9378195541697423"},"_hasShrinkwrap":false}},"time":{"created":"2022-12-18T21:04:41.692Z","0.0.3":"2022-12-18T21:04:41.916Z","modified":"2022-12-18T21:04:42.067Z"},"maintainers":[{"name":"flaviostutz","email":"flaviostutz@gmail.com"}],"description":"Middy middleware for feature flag control based on AWS AppConfig","homepage":"https://github.com/flaviostutz/appconfiger#readme","repository":{"type":"git","url":"git+https://github.com/flaviostutz/appconfiger.git"},"author":{"name":"flaviostutz"},"bugs":{"url":"https://github.com/flaviostutz/appconfiger/issues"},"license":"MIT","readme":"# idempotender\n\nMiddy middleware for configuring AWS Lambda Functions using AWS AppConfig.\n\nYou can automatically enable/disable a function based on a certain feature flag, or in more complex scenarios you can get the full configuration from `request.context.appconfiger` for more advanced tweaks in your function.\n\n## Usage\n\n- `npm install --save @appconfiger/middy`\n\n### Example: Enable/disable a Lambda function based on feature flag state\n\n- In this example the function will automatically refuse all requests if the feature flag 'myFunctionFlag' is disabled or inexistent in AppConfig.\n\n- Create Lambda function\n\n```js\nimport appConfigerMiddy from '@appconfiger/middy';\n\nconst handler = middy((event, context) => {\n  console.log(`Running function on ${new Date()}`);\n  return { message: `This function was run on ${new Date()}` };\n});\n\nhandler.use(\n  appConfigerMiddy({\n    applicationId: 'aaaaa', //from AppConfig\n    configurationProfileId: 'bbbbb', //from AppConfig\n    environmentId: 'ccccc', //from AppConfig\n    featureFlag: 'myFunctionFlag',\n  }),\n);\n```\n\n## Reference\n\n### Configuration\n\n```js\nconst idem = appConfigerMiddy({\n  applicationId: '[APP ID IN APPCONFIG]',\n  configurationProfileId: '[CONFIG PROFILE ID IN APPCONFIG]',\n  environmentId: '[ENV ID IN APPCONFIG]',\n  featureFlag: '[FLAG NAME IN APP CONFIG]',\n  pollingInterval: 300,\n}\n```\n\n- Config attributes\n\n  - **applicationId**\n\n    - Application name as defined in AppConfig. Required.\n\n  - **configurationProfileId**\n\n    - Configuration Profile Id as defined in AppConfig. Required.\n\n  - **environmentId**\n\n    - Environment Id as defined in AppConfig. Required.\n\n  - **featureFlag**\n\n    - Feature flag name. Required.\n    - This Lambda function will be enabled only if there is a enabled feature flag with this same name in AppConfig\n    - If you use an empty string as the name, this function will be always enabled and you can get AppConfig configurations from `context.appconfiger` for more complex checks.\n\n  - **pollingInterval**\n\n    - Interval in seconds for checking if there is a newer configuration in AppConfig\n    - During this period the latest version of the configuration will be available\n    - The polling is performed in background, so your function won't wait for the polling to finish before being run\n    - Defaults to 300 (5 minutes)\n\n### Handler context\n\nWhen your function is called, you can access the attribute `appconfiger` in the context of the handler for accessing the complete configuration object.\n\n- If the configuration in AppConfig is of type 'application/json', which is the most common situation, you will have a parsed object in the context.\n\n- When using the 'feature flag' type of configuration in AppConfig, implicitly you are using 'application/json' and in this attribute you will have access to the complete list of feature flags and its inner attributes (as you configured in AppConfig). For example:\n\n```js\ncontext.appconfiger >>>\n  {\n    featureFlag1: {\n      enabled: true,\n      customData1: 123,\n    },\n    featureFlag2: {\n      enabled: false,\n    },\n  };\n```\n","readmeFilename":"README.md"}