ConstCreates a new unexported article entity with its domain event.
As the aggregate root, Article is the only entry point for creating and managing article entities. All article-related operations must go through this factory to ensure domain invariants are maintained.
Provides immutable entity creation following DDD patterns. All returned entities are frozen using Object.freeze(). Returns a tuple of [entity, event] for domain event dispatching.
// Create a new unexported article with its domain event
const [article, event] = articleEntity.create({
userId: makeUserId("user-123"),
categoryName: makeCategoryName("Tech"),
title: makeArticleTitle("Article Title"),
url: makeUrl("https://example.com"),
caller: "addArticle",
});
// Persist and dispatch event
await repository.create(article);
await eventDispatcher.dispatch(event);
ArticlesDomainService for invariant validation (duplicate URL check)
Factory object for Article domain entity operations.
This is the Aggregate Root for the Articles bounded context.