clean up wants flow and http usage

This commit is contained in:
ntr committed 2022-11-28 10:31:37 +11:00
1 parent e74ab36313
commit 631942bb41
8 files changed
+30 -34

No files matched your search

+1 -1
View File
@@ -28,7 +28,7 @@ async function start() {
events,
} = createServices(log);
events.emit(Events.StartupSync);
// events.emit(Events.StartupSync);
// events.emit(Events.ListingsUpdated);
api.listen();
-15
View File
@@ -59,13 +59,6 @@ export default function createApi(log: Log, pg: Pg, discogs, offers, events) {
ctx.status = 200;
});
router.get('/user/offers', async function userOffersGet(ctx, next) {
ctx.assert(ctx.isAuthenticated(), 401, 'log in required');
const user = ctx.state.user;
const offers = await pg.userOffers(user);
ctx.response.body = offers;
});
router.post('/want', async function wantPost(ctx, next) {
ctx.assert(ctx.isAuthenticated(), 401, 'log in required');
const { releaseId } = ctx.request.body;
@@ -85,14 +78,6 @@ export default function createApi(log: Log, pg: Pg, discogs, offers, events) {
ctx.response.body = wants;
});
router.get('/want/all', async function wantGet(ctx, next) {
ctx.assert(ctx.isAuthenticated(), 401, 'log in required');
const user = ctx.state.user;
const wants = await pg.wantList(user);
ctx.response.body = wants;
});
router.post('/want/search', async function wantSearch(ctx, next) {
const { query } = ctx.request.body;
const results = await discogs.search(query);
+1
View File
@@ -51,6 +51,7 @@ export default function createEvents(log: Log, pg: Pg, discogs, offers) {
log.info({ event: Events.WantsAdded, wants: wants.map(w => wantDetails(w)) }, 'starting listings population');
await updateWantListings(wants);
log.info({ event: Events.WantsAdded, wants: wants.map(w => wantDetails(w)) }, 'finished populating listings');
events.emit(Events.ListingsUpdated);
});
events.on(Events.StartupSync, async function startupSync() {