-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/async storage #94
Conversation
f3f4ac1
to
d0fbf55
Compare
get transaction() { return ctx.transaction }, | ||
get logger() { return ctx.logger } | ||
}, | ||
() => next() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just be next
, no need to wrap a function in a function ;)
Object.defineProperties(app, { | ||
requestLocalStorage: { value: requestLocalStorage }, | ||
locals: { get() { return requestLocalStorage.getStore() ?? {} } } | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename these:
requestStorage
requestLocals
And let's move the defineProperties() monkey-patching to the Application
class properly:
constructor(...) {
this.requestStorage = new AsyncLocalStorage()
...
}
get requestLocals() {
return this.requestStorage.getStore() ?? {}
}
@@ -0,0 +1,17 @@ | |||
import { AsyncLocalStorage } from 'async_hooks' | |||
|
|||
export function setupRequestLocalStorage(app) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just setupRequestStorage()
then
19cd9f1
to
8c14378
Compare
79468ed
to
d00f104
Compare
@ptoussai great, thanks! |
No description provided.