Hybrid application
When we first started our microservice implementation in this chapter, we modified the bootstrap method to call connectMicroservice
. This is a special method that converts our Nest.js application into a hybrid application. This simply means our application now contains multiple context types. Simple enough but this has some implications that you should be aware of. Specifically, using the hybrid application approach, you will no longer be able to attach global filters, pipes, guards, and interceptors for the NestMicroservice context. This is because the NestMicroservice context is immediately bootstrapped, but not connected, in a hybrid application. To get around this limitation, we can create our two contexts independently.
async
function
bootstrap() {
const
app
=
await
NestFactory
.
create
(
AppModule
);
const
rpcApp
=
await
NestFactory
.
createMicroservice
(
AppModule
,
microserviceServerConfig
(
'nestjs_book'
));
rpcApp
.
useGlobalFilters
(
new
RpcValidationFilter...