Files
puaros/packages/core/src/domain/events/DomainEvent.ts
imfozilbek 2bdfc5382f feat(core): add domain layer with clean architecture
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
2025-11-23 21:43:34 +05:00

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;
}
}