Thanks for the suggestions here. I implemented something similar after reading this, but I'm wondering if there is really a need for the promise. In my case, what I did was create an exports.deps that returns an object like { s3: new AWS.S3() } and then I also created an exports.initDeps, which gets the object from exports.deps, and then assigns it to the top level variable. I have a fairly complex lambda, and I wanted to be able to test functions independently. So now the handler is the only function that calls exports.deps, and in my test code I overwrite initDeps, and then call any of the functions.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the suggestions here. I implemented something similar after reading this, but I'm wondering if there is really a need for the promise. In my case, what I did was create an exports.deps that returns an object like { s3: new AWS.S3() } and then I also created an exports.initDeps, which gets the object from exports.deps, and then assigns it to the top level variable. I have a fairly complex lambda, and I wanted to be able to test functions independently. So now the handler is the only function that calls exports.deps, and in my test code I overwrite initDeps, and then call any of the functions.