Pergunta comum em entrevista de NestJS. A resposta abaixo está em inglês, do jeito que dá para falar numa entrevista: leia, feche e tente explicar com as suas palavras.
Middleware: runs FIRST, before everything.
Guard: checks if the user is ALLOWED.
Interceptor: runs logic BEFORE and AFTER the controller.
Pipe: validates or transforms incoming data.
Exception Filter: shapes the response for an uncaught exception in the request lifecycle. It does not receive exceptions already handled by application code.
Successful request: Middleware → Guards → Interceptors (pre) → Pipes → Controller/Service → Interceptors (post). An uncaught exception skips the remaining normal path and reaches the applicable exception filter. Filters are an error path, not a mandatory final step.
Source: NestJS request lifecycle.
Ler é o primeiro passo. No app, essa pergunta vira flashcard com repetição espaçada, e o módulo tem quiz e simulado para testar o que ficou.
Treinar essa pergunta no app