For example when i create CRUD of blog
Usecase : Delete Article
When i delete article, need to remove comment.
But when create comment, need to validation article
// article-comment.service.ts
async createComment(articleId: string, comment: string) {
const article = articleService.get(articleId)
if (!article) throw new SomeException()
// ... create comment
}
async remove(articleId) {
}
// article.service.ts
async deleteArticle(articleid: string) {
// ... validation
commentService.remove(articleId)
}
async get(articleId: string) {
return repository.find(articleId)
}
articleService and commentService have circular dependency, How can i avoid it?
I don’t want to use ForwardRef..
Someone says, use EventEmitter and Use SharedModule? But What’s the best way i didn’t know..
Please give me advice, Thank you
Nestjs, Architecture