aws-sdk-wrap
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -14,29 +14,33 @@ const get = require('lodash.get'); | ||
const services = {}; | ||
const getService = service => { | ||
if (services[service] === undefined) { | ||
services[service] = new AWS[serviceLookup[service]](config); | ||
} | ||
return services[service]; | ||
}; | ||
return { | ||
call: (service, funcName, params, { | ||
expectedErrorCodes = [] | ||
} = {}) => { | ||
if (services[service] === undefined) { | ||
services[service] = new AWS[serviceLookup[service]](config); | ||
} = {}) => getService(service)[funcName](params).promise().catch(e => { | ||
if (expectedErrorCodes.indexOf(e.code) !== -1) { | ||
return e.code; | ||
} | ||
return services[service][funcName](params).promise().catch(e => { | ||
if (expectedErrorCodes.indexOf(e.code) !== -1) { | ||
return e.code; | ||
} | ||
if (logger !== null) { | ||
logger.error({ | ||
message: `Request failed for ${service}.${funcName}()`, | ||
errorName: get(e, "constructor.name"), | ||
errorDetails: e, | ||
requestParams: params | ||
}); | ||
} | ||
if (logger !== null) { | ||
logger.error({ | ||
message: `Request failed for ${service}.${funcName}()`, | ||
errorName: get(e, "constructor.name"), | ||
errorDetails: e, | ||
requestParams: params | ||
}); | ||
} | ||
throw e; | ||
}); | ||
} | ||
throw e; | ||
}), | ||
get: getService | ||
}; | ||
}; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJnZXQiLCJyZXF1aXJlIiwiQVdTIiwic2VydmljZUxvb2t1cCIsIk9iamVjdCIsImtleXMiLCJyZWR1Y2UiLCJwcmV2IiwiY3VyIiwiYXNzaWduIiwidG9Mb3dlckNhc2UiLCJtb2R1bGUiLCJleHBvcnRzIiwiY29uZmlnIiwibG9nZ2VyIiwic2VydmljZXMiLCJjYWxsIiwic2VydmljZSIsImZ1bmNOYW1lIiwicGFyYW1zIiwiZXhwZWN0ZWRFcnJvckNvZGVzIiwidW5kZWZpbmVkIiwicHJvbWlzZ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mljZXNbc2VydmljZV0gPSBuZXcgQVdTW3NlcnZpY2VMb29rdXBbc2VydmljZV1dKGNvbmZpZyk7XG4gICAgICB9XG4gICAgICByZXR1cm4gc2VydmljZXNbc2VydmljZV1bZnVuY05hbWVdKHBhcmFtcykucHJvbWlzZSgpLmNhdGNoKChlKSA9PiB7XG4gICAgICAgIGlmIChleHBlY3RlZEVycm9yQ29kZXMuaW5kZXhPZihlLmNvZGUpICE9PSAtMSkge1xuICAgICAgICAgIHJldHVybiBlLmNvZGU7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGxvZ2dlciAhPT0gbnVsbCkge1xuICAgICAgICAgIGxvZ2dlci5lcnJvcih7XG4gICAgICAgICAgICBtZXNzYWdlOiBgUmVxdWVzdCBmYWlsZWQgZm9yICR7c2VydmljZX0uJHtmdW5jTmFtZX0oKWAsXG4gICAgICAgICAgICBlcnJvck5hbWU6IGdldChlLCBcImNvbnN0cnVjdG9yLm5hbWVcIiksXG4gICAgICAgICAgICBlcnJvckRldGFpbHM6IGUsXG4gICAgICAgICAgICByZXF1ZXN0UGFyYW1zOiBwYXJhbXNcbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aHJvdyBlO1xuICAgICAgfSk7XG4gICAgfVxuICB9O1xufTtcbiJdfQ== | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJnZXQiLCJyZXF1aXJlIiwiQVdTIiwic2VydmljZUxvb2t1cCIsIk9iamVjdCIsImtleXMiLCJyZWR1Y2UiLCJwcmV2IiwiY3VyIiwiYXNzaWduIiwidG9Mb3dlckNhc2UiLCJtb2R1bGUiLCJleHBvcnRzIiwiY29uZmlnIiwibG9nZ2VyIiwic2VydmljZXMiLCJnZXRTZXJ2aWNlIiwic2VydmljZSIsInVuZGVmaW5lZCIsImNhbGwiLCJmdW5jTmFtZSIsInBhcm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gdW5kZWZpbmVkKSB7XG4gICAgICBzZXJ2aWNlc1tzZXJ2aWNlXSA9IG5ldyBBV1Nbc2VydmljZUxvb2t1cFtzZXJ2aWNlXV0oY29uZmlnKTtcbiAgICB9XG4gICAgcmV0dXJuIHNlcnZpY2VzW3NlcnZpY2VdO1xuICB9O1xuXG4gIHJldHVybiB7XG4gICAgY2FsbDogKHNlcnZpY2UsIGZ1bmNOYW1lLCBwYXJhbXMsIHsgZXhwZWN0ZWRFcnJvckNvZGVzID0gW10gfSA9IHt9KSA9PiBnZXRTZXJ2aWNlKHNlcnZpY2UpW2Z1bmNOYW1lXShwYXJhbXMpXG4gICAgICAucHJvbWlzZSgpLmNhdGNoKChlKSA9PiB7XG4gICAgICAgIGlmIChleHBlY3RlZEVycm9yQ29kZXMuaW5kZXhPZihlLmNvZGUpICE9PSAtMSkge1xuICAgICAgICAgIHJldHVybiBlLmNvZGU7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKGxvZ2dlciAhPT0gbnVsbCkge1xuICAgICAgICAgIGxvZ2dlci5lcnJvcih7XG4gICAgICAgICAgICBtZXNzYWdlOiBgUmVxdWVzdCBmYWlsZWQgZm9yICR7c2VydmljZX0uJHtmdW5jTmFtZX0oKWAsXG4gICAgICAgICAgICBlcnJvck5hbWU6IGdldChlLCBcImNvbnN0cnVjdG9yLm5hbWVcIiksXG4gICAgICAgICAgICBlcnJvckRldGFpbHM6IGUsXG4gICAgICAgICAgICByZXF1ZXN0UGFyYW1zOiBwYXJhbXNcbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICB0aHJvdyBlO1xuICAgICAgfSksXG4gICAgZ2V0OiBnZXRTZXJ2aWNlXG4gIH07XG59O1xuIl19 |
{ | ||
"name": "aws-sdk-wrap", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Wrapper around aws-sdk", | ||
@@ -31,3 +31,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"aws-sdk": "2.296.0", | ||
"aws-sdk": "2.298.0", | ||
"babel-cli": "7.0.0-beta.3", | ||
@@ -34,0 +34,0 @@ "babel-eslint": "8.2.6", |
@@ -47,2 +47,4 @@ [![Build Status](https://img.shields.io/travis/simlu/aws-sdk-wrap/master.svg)](https://travis-ci.org/simlu/aws-sdk-wrap) | ||
One can access an `aws-sdk` service directly by calling e.g. `aws.get('s3')`. | ||
### Init Options | ||
@@ -49,0 +51,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10592
36
75