Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR 설명
✅ 완료한 기능 명세
📸 스크린샷
고민과 해결과정
기존 코드의 문제점
해결
ThreadLocalStorage
를 활용하여 트랜잭션을 구현하는 것처럼 노드에서는 asyncLocalStorage를 활용할 수 있음asyncLocalStorage에 쿼리러너를 저장해서 한 요청에서 계속 그 스토리지에 접근해서 값을 전역으로 이용할 수 있다.
이를 활용해서 트랜잭션을 담당하는 데코레이터를 만들어서 처리.
NestJS 라이프 사이클에 맞는 데코레이터를 만들어주는 것이 어려웠는데,
메타데이터를 등록해주고, OnModuleInit, DiscoveryService를 이용해서 데코레이터를 만들수 있었다.
참고
https://toss.tech/article/nestjs-custom-decorator
https://github.com/boostcampwm2023/iOS02-moti/tree/develop
https://nodejs.org/api/async_context.html#asynclocalstoragegetstore