diff --git a/src/db-wrapper.js b/src/db-wrapper.js index 65d7a2c6..a0595d19 100644 --- a/src/db-wrapper.js +++ b/src/db-wrapper.js @@ -13,15 +13,21 @@ import createDynamoDBService from './db.js'; import serviceWrap from './service-wrap.js'; export default function dynamoDBWrapper(func) { - const region = process.env.AWS_REGION; - if (!region) { - throw Error('Please define region in secrets'); - } - return (request, context) => serviceWrap( - func, - request, - { ...context, region }, - '__ow_dynamodb', - createDynamoDBService, - ); + return async (...args) => { + let params = {}; + let context; + [params, context = {}] = args; + const region = process.env.AWS_REGION; + if (!region) { + throw Error('Please define region in secrets'); + } + context = { ...context, region }; + serviceWrap( + params, + context, + '__ow_dynamodb', + createDynamoDBService, + ); + return func(...args); + }; } diff --git a/src/service-wrap.js b/src/service-wrap.js index f7c98221..f69c5df0 100644 --- a/src/service-wrap.js +++ b/src/service-wrap.js @@ -10,7 +10,6 @@ * governing permissions and limitations under the License. */ export default function serviceWrap( - lambdaFn, lambdaRequest, lambdaContext, paramName, @@ -22,5 +21,4 @@ export default function serviceWrap( // eslint-disable-next-line no-param-reassign lambdaContext[paramName] = factoryFn(lambdaContext); } - return lambdaFn(lambdaContext); }