mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-27 23:06:54 +05:00
Add domain layer components: - BaseEntity with ID, timestamps and equality checks - ValueObject for immutable value objects - IRepository interface for persistence - DomainEvent system for domain events
25 lines
580 B
TypeScript
25 lines
580 B
TypeScript
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
/**
|
|
* Base interface for all domain events
|
|
*/
|
|
export interface IDomainEvent {
|
|
readonly eventId: string;
|
|
readonly occurredOn: Date;
|
|
readonly eventType: string;
|
|
}
|
|
|
|
/**
|
|
* Base class for domain events
|
|
*/
|
|
export abstract class DomainEvent implements IDomainEvent {
|
|
public readonly eventId: string;
|
|
public readonly occurredOn: Date;
|
|
public readonly eventType: string;
|
|
|
|
constructor(eventType: string) {
|
|
this.eventId = uuidv4();
|
|
this.occurredOn = new Date();
|
|
this.eventType = eventType;
|
|
}
|
|
} |