Conclusion is to not use thread-local storage. Instead:
[ ] create a requestContext object that gets initialized in main-app. This will have getRequestId() and getUserId() and getAppSource(), as well as references to request and response
[ ] pass this object around everywhere
[ ] db.js should not expose an alexaDb or googleDb, but rather just accept the requestContext and choose one accordingly. That way, it doesn't need to get passed around as well
[x] logger.js should also just accept a requestContext, event and data
Conclusion is to not use thread-local storage. Instead:
requestContext
object that gets initialized inmain-app
. This will havegetRequestId()
andgetUserId()
andgetAppSource()
, as well as references torequest
andresponse
db.js
should not expose analexaDb
orgoogleDb
, but rather just accept therequestContext
and choose one accordingly. That way, it doesn't need to get passed around as welllogger.js
should also just accept arequestContext
,event
anddata