-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Configuration for microservice in hybrid application #4261
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
Comments
Are you able to globally bind interceptors and guards using custom providers, e.g. {
provide: APP_INTERCEPTOR,
useClass: InterceptorClass
} |
That's how i'm currently doing it. But the APP_INTERCEPTOR is set using NestFactory.createApplicationContext -> NestFactory.initialize -> Scanner.applyApplicationProviders -> Scanner.getApplyProvidersMap -> it then adds the global interceptor to the ApplicationConfig but the ApplicationConfig instance is not used when running |
Oh, that's super interesting. I haven't had a chance to play around with Hybrid Applications much, so that's good to know. |
Maybe we can add an additional argument to the const transportOptions = {
transport: Transport.GRPC,
options: {}
};
app.connectMicroservice(transportOptions, { inheritAppConfig: true }); |
Looks good to me. |
Out of curiosity, would this also affect apps with WebSockets? I'm working on a logging library and using the custom provider for globally binding interceptors doesn't seem to bind for gateways. Only HTTP calls. |
I not familiar with WS implementation, but after a quick look I don't think this is the same issue |
Hi, i'm also facing this same issue, my global interceptor is ignored in microservices, I see the pull request has been made, is there anything I can help to make it merge? Thank you |
Hi, |
@2Kable I'll take care of this, no worries! Thanks |
Added in 7.1.0. Thanks! |
Feature Request
related to: #4112
Is your feature request related to a problem? Please describe.
We are running NestJS container that run a HTTP/GraphQL api, but also process GRPC, Queuing requests, in the same nestjs instance
I would like to run grpc alongside the graphql/http instance, and being able to intercept all request to log them, whether they are from GRPC or HTTP, using
app.useGlobalInterceptors
Describe the solution you'd like
We fixed it by patching nest source code and passing the
NestApplication
config in theNestMicroservice
constructorBut this would lead to a huge breaking change for current application that wants a separate configuration.
I would suggest an optional argument/property to pass to the
connectMicroservice
function to use or provide an existingApplicationConfig
instanceAnother solution could be adding a method to attach a
NestMicroservice
instance to the NestApplication without relying on connectMicroserviceWhat is the motivation / use case for changing the behavior?
I would expect that hybrid application can share the same
ApplicationConfig
.Not being able to set global guard/interceptors for nest-grpc running in an hybrid application, greatly reduce the experience of it.
The text was updated successfully, but these errors were encountered: