Our team is moving from aws-sdk v2 to v3. We have a common package that has a wrapper around aws-sdk which takes care of common logging to aws sdk service calls and update few configs ( This wrapper is not per client)
To elaborate it further, we define and import dependencies like this
"@aws-sdk": "^2.xxx" @aws-sdk/client-lambda":"^3.xxxWith the migration to v3. Which has per client module imports. I'm rewriting the wrapper.
I am wondering what is the best design pattern for doing a job like this? I am have been looking at the factory design pattern, but not sure if this is the correct one.
Given the requirements you specified I don't see anything wrong with a factory and since it's mandatory for V3 that you specify the service, I can't see how else you would do it other than to make the service info inputs to a factory of some sort. Especially if you're going to be using a wrapper anyway, moving the service import details from the import statement to the factory seems like you're not adding any additional code. I know you were probably looking for a more explicit pattern but I think what you're doing is correct given what you've outlined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With