पाठ 34 / 34
मुख्य Takeaways
NestJS के मुख्य विचार दोहराएँ: modules, controllers, services, dependency injection और request lifecycle का क्रम।
NestJS triangle
Modules आपके app को organize करते हैं, Controllers requests को handle करते हैं, Services logic contain करती हैं। सब कुछ Dependency Injection से जुड़ा है।
Request lifecycle
Request flow: Middleware → Guards → Interceptors (before) → Pipes → Controller/Handler → Interceptors (after) → Exception filters। सही debug करने के लिए यह क्रम सीखें।
Database patterns
Input के लिए DTOs का उपयोग करें; data access के लिए repositories; schema के लिए migrations। Business logic को services में, queries को repositories में रखें।
अंतिम क्विज़ 1/8
अंतिम क्विज़
त्वरित जाँच: NestJS module क्या करता है?
- Compiles TypeScript
- Opens database connections only
- Groups related controllers and providers
- Replaces Express
Answer
Groups related controllers and providers — Modules Nest app में व्यवस्था की इकाई हैं।
अंतिम क्विज़ 2/8
अंतिम क्विज़
त्वरित जाँच: Controller में services आमतौर पर कैसे मिलती हैं?
- new Service()
- Global variables
- require() at runtime
- Constructor dependency injection
Answer
Constructor dependency injection — Nest का IoC container providers आपके लिए inject करता है।
अंतिम क्विज़ 3/8
अंतिम क्विज़
त्वरित जाँच: कौन-सा component आने वाले data को validate और transform करता है?
- Pipe
- Guard
- Filter
- Module
Answer
Pipe — ValidationPipe handler से पहले DTOs जाँचता है।
अंतिम क्विज़ 4/8
अंतिम क्विज़
त्वरित जाँच: कौन-सा component तय करता है कि request आगे जा सकती है (जैसे authorization)?
- Pipe
- Guard
- Interceptor
- Entity
Answer
Guard — Guards CanActivate लागू करते हैं और अनुमति देते या रोकते हैं।
अंतिम क्विज़ 5/8
अंतिम क्विज़
त्वरित जाँच: Request lifecycle का सही क्रम क्या है?
- Pipes, Guards, Middleware, Handler
- Handler, Pipes, Guards
- Middleware, Guards, Interceptors, Pipes, Handler
- Guards, Handler, Middleware
Answer
Middleware, Guards, Interceptors, Pipes, Handler — Interceptors pipes से पहले और handler के बाद फिर चलते हैं।
अंतिम क्विज़ 6/8
अंतिम क्विज़
त्वरित जाँच: ORMs में N+1 कौन-सी समस्या बताता है?
- Too many migrations
- Too many modules
- Slow compilation
- One query per related row instead of a join or batch
Answer
One query per related row instead of a join or batch — इससे बचने के लिए relations को join या batch से load करें।
अंतिम क्विज़ 7/8
अंतिम क्विज़
त्वरित जाँच: TypeORM में database schema को कौन-सा tool version करता है?
- Migrations
- Interceptors
- Pipes
- Decorators
Answer
Migrations — Migrations schema बदलाव record और replay करते हैं।
अंतिम क्विज़ 8/8
अंतिम क्विज़
त्वरित जाँच: NestJS के लिए multi-stage Docker build क्यों उपयोग करें?
- Faster TypeScript
- Smaller final image with only runtime files
- It is required by Nest
- To skip tests
Answer
Smaller final image with only runtime files — Build tools builder stage में रहते हैं; अंतिम image हल्की रहती है।