Skip to content
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: allow to pass promise as response #12

Merged
merged 1 commit into from
Dec 21, 2023

Conversation

maxime1992
Copy link
Contributor

No description provided.

@maxime1992 maxime1992 self-assigned this Dec 18, 2023
.github/workflows/main.yml Outdated Show resolved Hide resolved
.releaserc Outdated Show resolved Hide resolved
@maxime1992
Copy link
Contributor Author

@zakhenry I've made a pre-release to test in my current branch and this works really well. It's letting me delay a request and in the e2e test make sure that a loading page/spinner is displayed and then resolve that promise as soon as the check is done to let the grpc call finish.

@maxime1992 maxime1992 force-pushed the feat-allow-to-pass-promise-as-response branch from b13cc47 to 1879753 Compare December 18, 2023 16:50
@maxime1992 maxime1992 requested a review from zakhenry December 21, 2023 06:09
expect(route.request().method(), 'ALL gRPC requests should be a POST request').toBe('POST');

const grpcResponse = typeof response === 'function' ? response(readGrpcRequest(route.request())) : response;
const grpcResponseWrapped = typeof response === 'function' ? response(readGrpcRequest(route.request())) : response;
const grpcResponse = await Promise.resolve(grpcResponseWrapped);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor possible cleanup

const grpcResponse = await (typeof response === 'function' ? response(readGrpcRequest(route.request())) : response )

but I think they end up functionally equivalent anyway though one less call on the stack

@zakhenry zakhenry merged commit a594b0d into master Dec 21, 2023
1 check passed
Copy link

🎉 This PR is included in version 2.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants