-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: support promise api #31
Conversation
I'm sorry but this is not what the issue is about. We would like to support stores written with async functions, not creating a proxy. |
@mcollina Thanks for taking a look, unfortunately i have misunderstood the issue. Is there any existing promise-based store packages that the library would like to support? I could use it as reference and work on it. Cheers |
@SimenB wdyt? Do you know anything? |
What I originally requested was a way to use promises instead of callbacks in the API exposed by So what I wanted is essentially what this PR has implemented - wrap any callback APIs with promises. (as mentioned in the issue, |
@mcollina I can continue to work on it if you think this could be something to be added to the library. Currently the CI fails due to coverage which should not be too hard to fix. |
Great news! Could you fix the remaining tests @lokshunhung ? |
Sure, I can take a look next morning. It's 12am now so good night guys. |
Pull Request Test Coverage Report for Build 1428409433
💛 - Coveralls |
@mcollina I fixed the tests and updated the docs. It's ready now. |
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.
late suggestion for alternative approach, but current code works for my use cases 🙂
If the comment from @SimenB is resolved, I think this can be merged |
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.
this works fine for me as is (it adds what I originally requested in a nice and clean way), but I do think the API consistency should be solved first (to avoid potential churn)
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.
Lgtm. Good work
Could you clarify what you mean by "first"? |
Before landing this PR, as I think a unified API will remove the reason to promisify |
Yup! |
Reolves #24: This PR adds promise support for
FastifyRequest#destroySession
and theget
,set
,destroy
methods onFastifyInstance#sessionStore
.The session store methods are wrapped with a new function to inspect whether a callback argument is passed, and will return a promise if the callback is missing. This approach does not mutate/monkey-patch methods on the store instance to avoid breaking anything. Tests for this are included here.
Checklist
npm run test
andnpm run benchmark
and the Code of conduct