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

gRPC server interceptor support? #115

Closed
hugebdu opened this issue Jun 17, 2021 · 2 comments
Closed

gRPC server interceptor support? #115

hugebdu opened this issue Jun 17, 2021 · 2 comments

Comments

@hugebdu
Copy link
Contributor

hugebdu commented Jun 17, 2021

Is there one or any plans to have?
couldn't find anything in docs/examples.

PS grpc-js doesn't support it

@timostamm
Copy link
Owner

For gRPC-servers, we generate service interfaces like this and service definitions like this.

The interface, your implementation and the service definition are intended to be used with the official gRPC package for node.js, wich is well maintained, written in type script and feature complete as far as I'm aware. I am pretty sure the package supports server side interceptors as well, but I do not actually know how at the top of my head. I'm happy to take a code snippet or PR to add to the example.

There is an alternative way to implement gRPC servers. The idea is to generate interfaces that do not depend on a specific type of transport, so that you could provide a single service implementation via gRPC, Twirp, etc. without additional implementation work. This is tracked in #56 and in alpha status. Example for such a generic service, served with a @grpc-js server, see here. You would add interceptors the same way as above.

@hugebdu
Copy link
Contributor Author

hugebdu commented Jun 20, 2021

@timostamm thank you for your reply.

I couldn't find any server side interceptors, neither in the listing of features nor in the code itself. And as I mentioned earlier, it looks like it isn't in the priorities for now.

Currently ended up with wrapping the implementation with JS proxy and putting all the interception logic inside.
But wanted to validate there's no workaround in protobuf-ts land.

Thanks again and cheers.

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

No branches or pull requests

2 participants