All quizzesHard
Execution Order & Scopes — Series 3
Preview — 3 of 10 questions
Do message handlers get the validation pipe?
javascript
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe({ whitelist: true }));
app.connectMicroservice<MicroserviceOptions>({ transport: Transport.RMQ, options });
await app.startAllMicroservices();
await app.listen(3000);AYes — useGlobalPipes applies to every entry point in the process
BNo, and nothing can change that: microservice handlers never support pipes
CYes, but only for handlers declared in the root module
DNo: enhancers registered through useGlobalX are attached to the HTTP application, so the connected microservice starts without them — passing { inheritAppConfig: true } to connectMicroservice shares them, and registering through APP_PIPE instead covers both automatically because the provider is part of the module graph
What does the interceptor do here?
javascript
@UseInterceptors(TransformInterceptor) // map(v => ({ data: v }))
@Sse('events')
events(): Observable<MessageEvent> { return this.bus.stream(); }AIt runs once, when the connection is established, and its transformation is discarded
BIts operators apply to every value the stream emits, not once per request — so an envelope intended for a single JSON response is applied to each event, usually producing a shape the client does not expect
CIt is skipped, since SSE routes bypass the enhancer chain
DIt buffers the stream and emits the transformed values when it completes
The handler returns null. What does the client receive?
javascript
intercept(ctx: ExecutionContext, next: CallHandler) {
return next.handle().pipe(filter((value) => value !== null));
}AA 500, because the response pipeline requires a value
Bnull serialised as the body, since filter applies only to arrays
CA success status with an empty body — the stream completed without emitting, so there is nothing to serialise, and the status still comes from the route's default or @HttpCode()
DThe request hangs until the client times out
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.