mirror of
https://github.com/YuzuZensai/Minikura.git
synced 2026-09-13 10:49:21 +00:00
♻️ refactor: remove unused code
This commit is contained in:
@@ -5,7 +5,6 @@ type EventHandler<T extends DomainEvent = DomainEvent> = (event: T) => void | Pr
|
||||
|
||||
export class EventBus {
|
||||
private handlers = new Map<string, Set<EventHandler>>();
|
||||
private eventHistory: DomainEvent[] = [];
|
||||
|
||||
subscribe<T extends DomainEvent>(
|
||||
eventClass: { new (...args: any[]): T },
|
||||
@@ -22,7 +21,6 @@ export class EventBus {
|
||||
}
|
||||
|
||||
async publish<T extends DomainEvent>(event: T): Promise<void> {
|
||||
this.eventHistory.push(event);
|
||||
const eventName = event.constructor.name;
|
||||
const handlers = this.handlers.get(eventName) || [];
|
||||
for (const handler of handlers) {
|
||||
@@ -33,14 +31,6 @@ export class EventBus {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getHistory(): DomainEvent[] {
|
||||
return [...this.eventHistory];
|
||||
}
|
||||
|
||||
clearHistory(): void {
|
||||
this.eventHistory = [];
|
||||
}
|
||||
}
|
||||
|
||||
export const eventBus = new EventBus();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
UserSuspendedEvent,
|
||||
UserUnsuspendedEvent,
|
||||
} from "../../domain/events/server-lifecycle.events";
|
||||
} from "../../domain/events/user-lifecycle.events";
|
||||
import { eventBus } from "../event-bus";
|
||||
import { logger } from "../logger";
|
||||
|
||||
|
||||
@@ -8,12 +8,6 @@ export class PrismaUserRepository implements UserRepository {
|
||||
});
|
||||
}
|
||||
|
||||
async findByEmail(email: string): Promise<User | null> {
|
||||
return await prisma.user.findUnique({
|
||||
where: { email },
|
||||
});
|
||||
}
|
||||
|
||||
async findAll(): Promise<User[]> {
|
||||
return await prisma.user.findMany({
|
||||
orderBy: { createdAt: "desc" },
|
||||
@@ -39,8 +33,4 @@ export class PrismaUserRepository implements UserRepository {
|
||||
where: { id },
|
||||
});
|
||||
}
|
||||
|
||||
async count(): Promise<number> {
|
||||
return await prisma.user.count();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user