Refactor to store sync state in redis

This commit is contained in:
Dominic Ferrando
2026-06-23 14:24:01 -04:00
parent b4623a1224
commit 5bae0f067d
2 changed files with 46 additions and 32 deletions
+5 -3
View File
@@ -105,10 +105,11 @@ export const app = new Elysia()
.group("/sync", (app) =>
app
// Sync status
.get("/", async ({ }) => SyncService.state)
.get("/", async ({ }) => await SyncService.getState())
// Full sync
.post("/", async ({ }) => {
if (SyncService.state.isSyncing)
const syncState = await SyncService.getState();
if (syncState.isSyncing)
return status(409, { error: "Sync already in progress" });
await SyncService.sync();
@@ -116,7 +117,8 @@ export const app = new Elysia()
})
// Per-product sync
.post("/:printfulProductId", async ({ params }) => {
if (SyncService.state.isSyncing)
const syncState = await SyncService.getState();
if (syncState.isSyncing)
return status(409, { error: "Sync already in progress" });
await SyncService.sync(params.printfulProductId);