Request lifecycle NestJS ਵਿਚ ਭਦੀਆਂ ਦੀ ਸਟੀਕ ਲੜੀ ਹੈ ਜਿਸ ਵਿਚੋਂ ਇਕ request ਲੰਘਦا ਹੈ — middleware, guards, interceptors, pipes, handler, ਫਿਰ interceptors ਦੁਬਾਰਾ, ਅਤੇ ਗ਼ਲਤੀਆਂ ਉੱਤੇ exception filters। ਸਹੀ ਕ੍ਰਮ ਜਾਣਨਾ ਕਦੋਂ ਹਰ ਇਕ ਤਰਕ ਚਲਦਾ ਹੈ ਇਸ ਨੂੰ ਸਮਝਣ ਲਈ ਮਹੱਤਵਪੂਰਨ ਹੈ।
ਪੂਰਾ ਕ੍ਰਮ
Incoming Request
│
▼
1. MIDDLEWARE (Express-style; raw req/res; runs first)
│
▼
2. GUARDS (authorization — return true to continue, false/throw to block)
│
▼
3. INTERCEPTORS (pre) (logic BEFORE the handler — start timing, etc.)
│
▼
4. PIPES (validate/transform the handler's arguments — DTO validation)
│
▼
5. ROUTE HANDLER (your controller method runs)
│
▼
6. INTERCEPTORS (post) (logic AFTER the handler — transform the response)
│
▼
Response
✗ If an exception is thrown ANYWHERE above →
7. EXCEPTION FILTERS (catch it and format the error response)
