Some api cleanup

This commit is contained in:
Dominic Ferrando
2026-06-23 12:26:08 -04:00
parent 6fa3d78571
commit 736c770647
+24 -24
View File
@@ -11,7 +11,7 @@ import {
type Player, type Player,
} from "@blade-and-brawn/domain" } from "@blade-and-brawn/domain"
import { cors } from "@elysiajs/cors"; import { cors } from "@elysiajs/cors";
import { Elysia, NotFoundError } from "elysia"; import { Elysia, NotFoundError, status } from "elysia";
import { import {
PrintfulService, PrintfulService,
SyncService, SyncService,
@@ -77,25 +77,27 @@ export const app = new Elysia()
// CALCULATOR // CALCULATOR
.post("/calculate", async ({ body }) => { .post("/calculate", async ({ body }) => {
const output = { return {
levels: levelCalculator.calculate(body.player, body.activityPerformances), levels: levelCalculator.calculate(body.player, body.activityPerformances),
}; };
// console.log({ log: query?.log });
// if (query?.log === "true") {
// void fetch("https://kv-logger.xominus.workers.dev", {
// method: "POST",
// headers: { "content-type": "application/json" },
// body: JSON.stringify({ output, player, activityPerformances }),
// }).catch(() => {});
// }
return output;
}, { }, {
body: z.object({ body: z.object({
player: PlayerSchema, player: PlayerSchema,
activityPerformances: z.array(ActivityPerformanceSchema) activityPerformances: z.array(ActivityPerformanceSchema)
}) }),
// afterResponse: ({ query, body, responseValue }) => {
// if (query.log === "true") {
// void fetch("https://kv-logger.xominus.workers.dev", {
// method: "POST",
// headers: { "content-type": "application/json" },
// body: JSON.stringify({
// output: responseValue,
// player: body.player,
// activityPerformances: body.activityPerformances
// }),
// });
// }
// }
}) })
// COMMERCE // COMMERCE
@@ -107,20 +109,18 @@ export const app = new Elysia()
// Sync status // Sync status
.get("/", async ({ }) => SyncService.state) .get("/", async ({ }) => SyncService.state)
// Full sync // Full sync
.post("/", async ({ set }) => { .post("/", async ({ }) => {
if (SyncService.state.isSyncing) { if (SyncService.state.isSyncing)
set.status = 409; return status(409, { error: "Sync already in progress" });
return { error: "Sync already in progress" };
}
await SyncService.sync(); await SyncService.sync();
return { ok: true }; return { ok: true };
}) })
// Per-product sync // Per-product sync
.post("/:printfulProductId", async ({ params, set }) => { .post("/:printfulProductId", async ({ params }) => {
if (SyncService.state.isSyncing) { if (SyncService.state.isSyncing)
set.status = 409; return status(409, { error: "Sync already in progress" });
return { error: "Sync already in progress" };
}
await SyncService.sync(params.printfulProductId); await SyncService.sync(params.printfulProductId);
return { ok: true }; return { ok: true };
}, { params: z.object({ printfulProductId: z.number() }) }), }, { params: z.object({ printfulProductId: z.number() }) }),