diff --git a/lib/build-plugin.js b/lib/build-plugin.js index 7bd68e3..9e9a46e 100644 --- a/lib/build-plugin.js +++ b/lib/build-plugin.js @@ -2,7 +2,7 @@ const fp = require('fastify-plugin') const pProps = require('p-props') -const pReduce = require('p-reduce') +const pMap = require('p-map') const DEFAULT_GET_CONCURRENCY = 5 @@ -33,7 +33,12 @@ function buildPlugin(Client, pluginOpts) { const concurrency = opts.concurrency || DEFAULT_GET_CONCURRENCY const secrets = Array.isArray(opts.secrets) - ? await pReduce(opts.secrets, async (acc, value) => ({ ...acc, [value]: await client.get(value) }), {}) + ? Object.assign( + {}, + ...(await pMap(opts.secrets, async (value) => ({ [value]: await client.get(value) }), { + concurrency + })) + ) : await pProps(opts.secrets, (value) => client.get(value), { concurrency }) const namespace = opts.namespace diff --git a/package.json b/package.json index dd56cbd..5e12606 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ }, "dependencies": { "fastify-plugin": "^3.0.0", - "p-props": "^4.0.0", - "p-reduce": "^2.1.0" + "p-map": "^4.0.0", + "p-props": "^4.0.0" }, "devDependencies": { "eslint": "^8.0.0",