{"_id":"@assetchain/parameter-store-discovery-client","_rev":"2-f940ac1369386d4309e4e661a0783f6c","name":"@assetchain/parameter-store-discovery-client","description":"Library that provides an easier access to AWS SSM Parameter store to use it as a resilient distributed key/value storage for service discovery.","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@assetchain/parameter-store-discovery-client","version":"1.0.0","description":"Library that provides an easier access to AWS SSM Parameter store to use it as a resilient distributed key/value storage for service discovery.","main":"lib/client.js","scripts":{"lint":"eslint src","lint-fix":"eslint src --fix","build":"npm run lint && jest && ./node_modules/.bin/babel src --out-dir lib --minified --no-comments","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/JB-AssetChain/parameter.store.discovery.nodejs.git"},"jest":{"verbose":true,"transform":{"^.+\\.js$":"babel-jest"},"globals":{"NODE_ENV":"test"},"moduleFileExtensions":["js"],"moduleDirectories":["node_modules","src"]},"author":{"name":"AssetChain"},"license":"MIT","devDependencies":{"babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-jest":"^21.2.0","babel-loader":"^7.1.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-runtime":"^6.23.0","babel-polyfill":"^6.23.0","babel-preset-env":"^1.6.0","babel-preset-es2015":"^6.24.1","babel-preset-stage-0":"^6.24.1","eslint":"^4.11.0","eslint-config-prettier":"^2.7.0","eslint-plugin-jest":"^21.5.0","eslint-plugin-prettier":"^2.3.1","jest":"^21.2.1","prettier":"^1.8.2","regenerator-runtime":"^0.11.1"},"dependencies":{"aws-sdk":"^2.176.0"},"gitHead":"4e880c2669fb02c30e57184ce2540f3e28801af2","bugs":{"url":"https://github.com/JB-AssetChain/parameter.store.discovery.nodejs/issues"},"homepage":"https://github.com/JB-AssetChain/parameter.store.discovery.nodejs#readme","_id":"@assetchain/parameter-store-discovery-client@1.0.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"assetchain","email":"dev@assetchain.com.au"},"dist":{"integrity":"sha512-cXe90mCwxJ15TLFoqtK6re3OL9YJLulwErxVCSn6QsKdKIy0wnNBI9SBVfw9CRibGo0eKkuT+keX90VmKE5lDQ==","shasum":"147202dc12a47b356a745e019cedb47ddc922aca","tarball":"https://registry.npmjs.org/@assetchain/parameter-store-discovery-client/-/parameter-store-discovery-client-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHpdalYIfsV1LMiqZSoGu2az6PbV3AyxhdNU8ulb+mpfAiAfzwadZCFg8iLzxjZHlWLWrwilba/ghSreZF3GdR/SfA=="}]},"maintainers":[{"name":"assetchain","email":"dev@assetchain.com.au"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/parameter-store-discovery-client-1.0.0.tgz_1515364944758_0.8888086879160255"}},"1.0.1":{"name":"@assetchain/parameter-store-discovery-client","version":"1.0.1","description":"Library that provides an easier access to AWS SSM Parameter store to use it as a resilient distributed key/value storage for service discovery.","main":"lib/client.js","scripts":{"lint":"eslint src","lint-fix":"eslint src --fix","build":"npm run lint && jest && ./node_modules/.bin/babel src --out-dir lib --minified --no-comments","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/JB-AssetChain/parameter.store.discovery.nodejs.git"},"jest":{"verbose":true,"transform":{"^.+\\.js$":"babel-jest"},"globals":{"NODE_ENV":"test"},"moduleFileExtensions":["js"],"moduleDirectories":["node_modules","src"]},"author":{"name":"AssetChain"},"license":"MIT","devDependencies":{"aws-sdk":"^2.180.0","babel-cli":"^6.26.0","babel-core":"^6.26.0","babel-jest":"^21.2.0","babel-loader":"^7.1.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-runtime":"^6.23.0","babel-polyfill":"^6.23.0","babel-preset-env":"^1.6.0","babel-preset-es2015":"^6.24.1","babel-preset-stage-0":"^6.24.1","eslint":"^4.11.0","eslint-config-prettier":"^2.7.0","eslint-plugin-jest":"^21.5.0","eslint-plugin-prettier":"^2.3.1","jest":"^21.2.1","prettier":"^1.8.2","regenerator-runtime":"^0.11.1"},"peerDependencies":{"aws-sdk":"^2.180.0"},"gitHead":"64dd7ecb075740e3c084a8b2e32a550451e94b21","bugs":{"url":"https://github.com/JB-AssetChain/parameter.store.discovery.nodejs/issues"},"homepage":"https://github.com/JB-AssetChain/parameter.store.discovery.nodejs#readme","_id":"@assetchain/parameter-store-discovery-client@1.0.1","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"assetchain","email":"dev@assetchain.com.au"},"dist":{"integrity":"sha512-KTzEciNKxryeTpsFRR+EyY/iEWmc0CnPrJ9n5QtkBrTi7WYpJqYDLUjtSPyy7TpQjAbd9cDKBhdKvUNykllRfg==","shasum":"e9363194d7448932f7aa5c281103bcd0a02e59d5","tarball":"https://registry.npmjs.org/@assetchain/parameter-store-discovery-client/-/parameter-store-discovery-client-1.0.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC7LJ3GFgIBqetHb77DXCVWolAxeKqvONK8VsJWbm7FUgIgcvhxISwt5L1rjuOMsmtvl2QYaLLXVWJHvNLh3TVz3Wg="}]},"maintainers":[{"name":"assetchain","email":"dev@assetchain.com.au"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/parameter-store-discovery-client-1.0.1.tgz_1515715589558_0.8063877569511533"}}},"readme":"# AWS SSM Parameter Store based discovery client\n\nLibrary that provides an easier access to AWS SSM Parameter store to use it\nas a resilient distributed key/value storage for service discovery.\n\nRead about AWS SSM Parameter Store [here](http://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html).\n\n## Install\n\n```\nnpm i --save aws-sdk @assetchain/parameter-store-discovery-client\n```\n\n## Example\n\nHere is the example how to use parameter discovery service in your lambda\n\n```js\nimport { ParameterDiscoveryService } from '@assetchain/parameter-store-discovery-client';\n\n// Init parameter\nconst store = new ParameterDiscoveryService({}, {stage: 'dev'});\n// You can prefetch some parameters outside of your lambda handler\n// Be aware that this is an async call and it may not be complete before handler executed\nstore.get([\n    '/services/accounts/baseUrl',\n    '/services/transactions/baseUrl',\n    '/services/transactions/timeout'\n]);\n\nexport async function handler(event, context, callback) {\n    // if you already have parameter fetched in line #26 then this will load it from a cache\n    const response = await fetch(store.get('/services/accounts/baseUrl'));\n    // if you don't have parameter fetched already - it will make a call and cache it for a some time\n    const response = await fetch(store.get('/services/accounts/random'));\n}\n```\n\n## Docs\n\n### new ParameterDiscoveryService([awsConfig: Object], [options: Object])\n\nWhere `awsConfig` is AWS SDK Configuration object that will be passed directly. It has many configuration options \nand uses this one as a default:\n- `region (defaults to process.env.REGION)`\n\nOptional arguments within options object are these: \n- `stage (defaults to process.env.STAGE)` - stage that will be used as a prefix for all your keys like `/${stage}/my/key/name`\n- `ttl (30000)` - time to live for your cache, new call will be made to AWS API if cache expired\n- `isFallbackEnabled (true)` - enable or disable `Fallback Mode` (read below)\n- `fallbackStage ('master')` - stage that will be used to search for parameter if main stage parameter not found\n- `isAutoRefreshEnabled (false)` - set a timeout to automatically refresh cache when it expires even if no get calls have been made. \nBe careful as internal SetInterval may prevent a shutdown of your lambda as you have to manually cancel `this.timeout`\n\nExample\n\n```js\nconst parameterDiscoveryService = new ParameterDiscoveryService({region: 'ap-southeast-2'}, {stage: 'dev', ttl: 120000});\n```\n\n### ParameterDiscoveryService.get(path: String, [options: Object]): Promise<Parameter>\n### ParameterDiscoveryService.get(paths: Array<String>, [options: Object]): Promise<Map<Parameter>>\n\nRetrieves a parameter or multiple parameters from the storage. It will automatically decrypt them if needed as `WithDecryption: true`\noption is set by default. Retrieved value will be stored in internal cache and retrived from there if it's not expired.\n\n`Parameter` has structure like\n```\n{\n    \"Name\": \"string\",\n    \"Type\": \"string\",\n    \"Value\": \"string\",\n    \"Version\": number\n}\n```\n\nPromise from `ParameterDiscoveryService.get(['something'], options)` will return a HashMap with parameters objects where promise from \n`ParameterDiscoveryService.get('something', options)` will return parameter object\n\n```js\nconst parameterDiscoveryService = new ParameterDiscoveryService({region: 'ap-southeast-2'}, {stage: 'dev'});\n\nasync printBaseUrl() {\n  const baseUrl = await parameterDiscoveryService.get('/service/accounts/baseUrl'); \n  \n  console.log(baseUrl.Value) // prints parameter from /dev/service/accounts/baseUrl\n}\n\nasync printManyParams() {\n  const parameters = await parameterDiscoveryService.get(['/service/accounts/baseUrl', '/service/transactions/limit']);\n  \n  console.log(parameters) // this is a hashMap so...\n  console.log(parameters.get('/service/accounts/baseUrl').Value) // prints parameter from /dev/service/accounts/baseUrl\n  console.log(parameters.get('/service/transactions/limit').Value) // prints parameter from /dev/service/transactions/limit\n}\n```\n\n### ParameterDiscoveryService.set(path: String, value: String|Array<String>, [options]): Promise<ParameterCreationResponse>\n\nSet parameter in AWS SSM Parameter Store. You can pass either string or array of strings here. Non strings values will be converted\nto strings.\n\nAWS Option for `Overwrite` set to `true` by default but you can overwrite it. \nYou can check [AWS API reference](http://docs.aws.amazon.com/systems-manager/latest/APIReference/API_PutParameter.html) for PutParameter\nto get a better idea what options you can pass through\n\n```js\nconst parameterDiscoveryService = new ParameterDiscoveryService({region: 'ap-southeast-2'}, {stage: 'dev'});\n\nasync updateBaseUrl(url) {\n  const result = await parameterDiscoveryService.set('/service/accounts/baseUrl', url);\n  console.log(result); // Something like {Version: 12}\n}\n```\n\n### ParameterDiscoveryService.setEncrypted(path: String, value: String, [options]): Promise<ParameterCreationResponse>\n\nThe same as `.set()` described above but option for parameter type set to `SecureString`. \nIf you don't specify a KMS key ID (`KeyId`), the system uses the default key associated with your AWS account.\n\n## Fallback Mode\n\nBy default this library operates with enabled Fallback Mode. That means if parameter wasn't found by `/${stage}/path/to/param` path\nthen library will try to retrieve it from `/${fallbackStage/path/to/param`. This is extremely useful if you deploy your branches \nnext to master when they can reach each other. If your branch don't have any configuration - it will fallback to use master parameters.\n\nYou can disable that behaviour or change fallback stage by defining and passing `isFallbackEnabled` and `fallbackStage` arguments\nto the constructor\n\n# Development\n\nBuild this library using `npm build` - that will run eslint + prettier checks and unit tests\n\n# License\n\nThe MIT License (MIT)\n=====================\n\nCopyright © 2017 AssetChain\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the “Software”), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n","maintainers":[{"name":"assetchain","email":"dev@assetchain.com.au"}],"time":{"modified":"2022-04-04T15:51:28.378Z","created":"2018-01-07T22:42:24.860Z","1.0.0":"2018-01-07T22:42:24.860Z","1.0.1":"2018-01-12T00:06:29.684Z"},"homepage":"https://github.com/JB-AssetChain/parameter.store.discovery.nodejs#readme","repository":{"type":"git","url":"git+https://github.com/JB-AssetChain/parameter.store.discovery.nodejs.git"},"author":{"name":"AssetChain"},"bugs":{"url":"https://github.com/JB-AssetChain/parameter.store.discovery.nodejs/issues"},"license":"MIT","readmeFilename":"README.md"}