NestJS Request Lifecycle (0) - ๊ฐœ์š”

2022. 12. 22. 16:09ใ†Backend/NestJS

NestJS๋Š” Node.js ๋ฐฑ์—”๋“œ ์ง„ํ˜•์˜ Express๊ฐ€ ํ•ด๊ฒฐํ•ด์ฃผ์ง€ ๋ชปํ–ˆ๋˜ ์•„ํ‚คํ…์ณ์— ๋Œ€ํ•œ ๊ณ ๋ฏผ์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด VueJS๋ฅผ ์ฐธ๊ณ ํ•˜์—ฌ Express๋ฅผ ๋ž˜ํ•‘ํ•œ ๋ฐฑ์—”๋“œ ํ”„๋ ˆ์ž„์›Œํฌ์ด๋‹ค. 

๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— NestJS์—๋Š” ํด๋ผ์ด์–ธํŠธ์˜ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด ํ”„๋ ˆ์ž„์›Œํฌ๊ฐ€ ์ œ๊ณตํ•˜๋Š” ์ผ๋ จ์˜ ์ƒ๋ช…์ฃผ๊ธฐ๊ฐ€ ์กด์žฌํ•œ๋‹ค. ์•„๋ž˜๋Š” NestJS ๊ณต์‹๋ฌธ์„œ์—์„œ ์„ค๋ช…ํ•˜๋Š” NestJS์˜ ์š”์ฒญ ์ƒ๋ช…์ฃผ๊ธฐ์ด๋‹ค.

(์ถœ์ฒ˜: https://docs.nestjs.com/faq/request-lifecycle)

  1. Incoming request
  2. Globally bound middleware
  3. Module bound middleware
  4. Global guards
  5. Controller guards
  6. Route guards
  7. Global interceptors (pre-controller)
  8. Controller interceptors (pre-controller)
  9. Route interceptors (pre-controller)
  10. Global pipes
  11. Controller pipes
  12. Route pipes
  13. Route parameter pipes
  14. Controller (method handler)
  15. Service (if exists)
  16. Route interceptor (post-request)
  17. Controller interceptor (post-request)
  18. Global interceptor (post-request)
  19. Exception filters (route, then controller, then global)
  20. Server response

์ด๋ฅผ ๋‚˜๋ฆ„๋Œ€๋กœ ์••์ถ•ํ•˜๋ฉด ๋‹ค์Œ์˜ ์ƒ๋ช…์ฃผ๊ธฐ๊ฐ€ ๋œ๋‹ค.

NestJS Request Lifecycle (์ถœ์ฒ˜: https://hotovo.com/2021/06/30/inside-nestjs-project/)

  1. Request
  2. Middleware
  3. Guard
  4. Interceptor
  5. Pipe
  6. Controller
  7. Interceptor
  8. Exception Filter
  9. Response 

์ด์— ๋Œ€ํ•ด ๊ณต๋ถ€๋„ ํ•˜๋Š” ๊น€์—, ๊ฐ ์ƒ๋ช…์ฃผ๊ธฐ์— ๋Œ€ํ•œ ๋‚ด์šฉ๋“ค์„ ์ •๋ฆฌํ•˜์—ฌ ๋ธ”๋กœ๊ทธ์— ๊ฒŒ์‹œํ•ด๋ณผ๊นŒ ํ•œ๋‹ค.

(๋ธ”๋กœ๊ทธ ์šฉ์ด๋ฉด ์Šค์Šค๋กœ ์ข€ ๋” ๊ผผ๊ผผํ•˜๊ณ  ๊พธ์ค€ํžˆ ๊ณต๋ถ€ํ•˜์ง€ ์•Š์„๊นŒ.....?)

'Backend > NestJS' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

NestJS Request Lifecycle (5) - Exception Filter  (0) 2023.01.13
NestJS Request Lifecycle (4) - Pipe  (0) 2022.12.29
NestJS Request Lifecycle (3) - Interceptor  (0) 2022.12.26
NestJS Request Lifecycle (2) - Guard  (0) 2022.12.23
NestJS Request Lifecycle (1) - Middleware  (0) 2022.12.22