Fix redis race condition
This commit is contained in:
@@ -126,22 +126,19 @@ export const app = new Elysia()
|
||||
.group("/sync", (app) =>
|
||||
app
|
||||
// Sync status
|
||||
.get("/", async ({ }) => await productSyncer.getState())
|
||||
.get("/", async ({ }) => ({
|
||||
state: await productSyncer.getState(),
|
||||
isRunning: await productSyncer.isRunning()
|
||||
}))
|
||||
// Full sync
|
||||
.post("/", async ({ }) => {
|
||||
const syncState = await productSyncer.getState();
|
||||
if (syncState.isSyncing)
|
||||
if (!await productSyncer.sync())
|
||||
throw status(409, "Sync already in progress");
|
||||
|
||||
await productSyncer.sync();
|
||||
})
|
||||
// Per-product sync
|
||||
.post("/:printfulProductId", async ({ params }) => {
|
||||
const syncState = await productSyncer.getState();
|
||||
if (syncState.isSyncing)
|
||||
if (!await productSyncer.sync(params.printfulProductId))
|
||||
throw status(409, "Sync already in progress");
|
||||
|
||||
await productSyncer.sync(params.printfulProductId);
|
||||
}, { params: z.object({ printfulProductId: z.coerce.number() }) }),
|
||||
)
|
||||
.get("/:printfulProductId", async ({ params }) => {
|
||||
|
||||
Reference in New Issue
Block a user