store events into a collection
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import { EventEmitter } from "stream";
|
||||
import { createEvent } from "./events/events.service";
|
||||
|
||||
export type ChangeEvent = {
|
||||
tenantId: string;
|
||||
type: "insert" | "update" | "delete";
|
||||
collection: "permits" | "orgs";
|
||||
orgId?: string;
|
||||
document?: Object;
|
||||
};
|
||||
|
||||
@@ -21,3 +24,7 @@ export type AlertEvent = {
|
||||
};
|
||||
|
||||
export const dbEvents = new EventEmitter();
|
||||
|
||||
dbEvents.on("change", async (event: ChangeEvent) => {
|
||||
await createEvent(event);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user