这是 NestJS 的核心通路图,必须背下来。
HTTP Request
↓
Middleware(可选,站外引导)
↓
Guard(是否允许进入)
↓
Interceptor(前置逻辑)
↓
Pipe(参数转换/校验)
↓
Controller(接待窗口)
↓
Service / Provider(业务调度)
↓
Repository / ORM / 外部系统
↓
Interceptor(后置包装)
↓
Response再压成一句更工程化的话:
Guard 决定“能不能进”
Pipe 决定“传进来的东西合不合法”
Controller 决定“该调用谁”
Service 决定“业务怎么做”
Interceptor 决定“过程和结果怎么统一编排”
Filter 决定“出事后怎么兜底”你一旦把这条链路看清,NestJS 就不再是 decorator 大杂烩。