additional typing
This commit is contained in:
1 parent
a0cd49b411
commit
7262d6b37b
5 files changed
+12
-6
No files matched your search
+1
-1
@@ -28,7 +28,7 @@ async function start() {
|
|||||||
events,
|
events,
|
||||||
} = createServices(log);
|
} = createServices(log);
|
||||||
|
|
||||||
// events.emit(Events.StartupSync);
|
events.emit(Events.StartupSync);
|
||||||
// events.emit(Events.ListingsUpdated);
|
// events.emit(Events.ListingsUpdated);
|
||||||
|
|
||||||
api.listen();
|
api.listen();
|
||||||
|
|||||||
+6
-4
@@ -13,9 +13,11 @@ import Bluebird from 'bluebird';
|
|||||||
import type Log from 'bunyan';
|
import type Log from 'bunyan';
|
||||||
import type { Listing, User, Want, Prisma } from '@prisma/client';
|
import type { Listing, User, Want, Prisma } from '@prisma/client';
|
||||||
|
|
||||||
import { Pg } from './pg';
|
import type { Pg } from './pg';
|
||||||
import { Discogs } from './discogs';
|
import type { Discogs } from './discogs';
|
||||||
import { Offers } from './offers';
|
import type { Offers } from './offers';
|
||||||
|
import type { Rpc } from './rpc';
|
||||||
|
|
||||||
import routerAuth from './routers/router.auth';
|
import routerAuth from './routers/router.auth';
|
||||||
import { Events } from './events';
|
import { Events } from './events';
|
||||||
import createRpc, { RpcMessageType } from './rpc';
|
import createRpc, { RpcMessageType } from './rpc';
|
||||||
@@ -120,7 +122,7 @@ export default function createApi(log: Log, pg: Pg, discogs: Discogs, offers: Of
|
|||||||
// log.child...
|
// log.child...
|
||||||
|
|
||||||
const ws = ctx.websocket;
|
const ws = ctx.websocket;
|
||||||
const rpc = createRpc(log, pg, ws, discogs, offers, ctx.state.user);
|
const rpc = createRpc(log, pg, ws, discogs, offers, ctx.state.user as User | null);
|
||||||
|
|
||||||
if (ctx.state.user) events.emit(Events.Connection, { ws, id: ctx.state.user.id });
|
if (ctx.state.user) events.emit(Events.Connection, { ws, id: ctx.state.user.id });
|
||||||
ws.on('message', async function incoming(message) {
|
ws.on('message', async function incoming(message) {
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ export default function createOffers(log: Log, pg: Pg) {
|
|||||||
// TODO probably need to take one of each condition of record from a store
|
// TODO probably need to take one of each condition of record from a store
|
||||||
// eg. they have a VG+ and a M we should make offers for each
|
// eg. they have a VG+ and a M we should make offers for each
|
||||||
|
|
||||||
log.info(sorted);
|
// log.info(sorted);
|
||||||
|
|
||||||
const inserts = await pg.offersUpdate(sorted);
|
const inserts = await pg.offersUpdate(sorted);
|
||||||
|
|
||||||
|
|||||||
@@ -169,6 +169,8 @@ export default function createPg(log: Log, prisma: PrismaClient) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
log.info({ count }, 'second stage open offers removed');
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,8 @@ export default function createRpc(log: Log, pg: Pg, ws, discogs: Discogs, offers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Rpc = ReturnType<typeof createRpc>;
|
||||||
|
|
||||||
export enum RpcMessageType {
|
export enum RpcMessageType {
|
||||||
Ping = 'Ping',
|
Ping = 'Ping',
|
||||||
Pong = 'Pong',
|
Pong = 'Pong',
|
||||||
|
|||||||
Reference in new issue
Block a user