want events
This commit is contained in:
1 parent
f5e75f4fe6
commit
30bf7426e4
19 files changed
+293
-108
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { EventEmitter } from 'node:events';
|
||||
|
||||
import type Log from 'bunyan';
|
||||
import type { Listing, User, Want, Prisma } from '@prisma/client';
|
||||
|
||||
import { Pg } from './pg';
|
||||
import routerAuth from './routers/router.auth';
|
||||
|
||||
export enum Events {
|
||||
WantsAdded = 'WantsAdded',
|
||||
}
|
||||
|
||||
export function eventService(log: Log, pg: Pg, discogs) {
|
||||
const events = new EventEmitter({ captureRejections: true });
|
||||
|
||||
events.on('error', function eventError(e) {
|
||||
log.error(e);
|
||||
});
|
||||
|
||||
events.on(Events.WantsAdded, async function wantsAdded(wants: Want[]) {
|
||||
log.info('wants added', wants);
|
||||
});
|
||||
|
||||
return events;
|
||||
}
|
||||
Reference in new issue
Block a user