Skip to content

Commit

Permalink
Modification on how configs are handle
Browse files Browse the repository at this point in the history
  • Loading branch information
marcogadget committed Sep 29, 2017
1 parent 0b78432 commit f3249cb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const getPromise = func => (method, params) => new Promise((resolve, reject) =>
});

// Exports DynamoDB function that returns an object of methods
module.exports = (region = 'eu-central-1', configPath) => {
module.exports = (region = 'eu-central-1', config) => {
AWS.config.update({ region });
if (process.env.DYNAMO_ENV === 'test') {
AWS.config.update({
Expand All @@ -15,8 +15,10 @@ module.exports = (region = 'eu-central-1', configPath) => {
secretAccessKey: process.env.DYNAMO_ENV,
endpoint: 'http://localhost:8000',
});
} else if (configPath) {
AWS.config.loadFromPath(configPath);
} else if (typeof config === 'string') {
AWS.config.loadFromPath(config);
} else if (typeof config === 'object') {
AWS.config.update(config);
}

const dynamoDB = new AWS.DynamoDB();
Expand Down

0 comments on commit f3249cb

Please sign in to comment.