diff --git a/src/db-wrapper.js b/src/db-wrapper.js index a0595d19..d6ae7050 100644 --- a/src/db-wrapper.js +++ b/src/db-wrapper.js @@ -15,13 +15,12 @@ import serviceWrap from './service-wrap.js'; export default function dynamoDBWrapper(func) { return async (...args) => { let params = {}; - let context; + let context = {}; [params, context = {}] = args; - const region = process.env.AWS_REGION; + const region = context.env.AWS_REGION; if (!region) { throw Error('Please define region in secrets'); } - context = { ...context, region }; serviceWrap( params, context, diff --git a/src/index.js b/src/index.js index 515577c7..c65be09b 100644 --- a/src/index.js +++ b/src/index.js @@ -47,7 +47,7 @@ async function run(request, context) { export const main = wrap(run) .with(helixStatus) - .with(dynamoDBWrapper) .with(logger.trace) .with(logger) - .with(secrets); + .with(secrets) + .with(dynamoDBWrapper);