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. |
|
If the comment from @SimenB is resolved, I think this can be merged |
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#destroySessionand theget,set,destroymethods 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 testandnpm run benchmarkand the Code of conduct