nestjs onModuleInit
onModuleInit 에 대하여…
요청때마다 생성자가 필요한 자원(인스턴스)들은 초기화는 onModuleInit을 통하는게아닌, 직접 Construct에 넣어서 초기화 해주어야 함.
사용시, @Injectable({scope: Scope:REQUEST}) 로 명시합니다.
Nest의 관리밖에서 GC에 의해 수거되기 위함.
요청 때마다 초기화되는 Correlation-Id를 기록하는 @Logger()를 사용하는 클래스일 경우 Scope:REQUEST로 동작합니다.
WARNING The lifecycle hooks listed above are not triggered for request-scoped classes. Request-scoped classes are not tied to the application lifecycle and their lifespan is unpredictable. They are exclusively created for each request and automatically garbage-collected after the response is sent.