Setting up calculator config management

This commit is contained in:
Dominic Ferrando
2026-07-04 00:39:57 -04:00
parent 87df874f75
commit 2eea7216d6
3 changed files with 45 additions and 14 deletions
+20 -13
View File
@@ -96,6 +96,7 @@ export const app = new Elysia()
status
}, "request");
})
.guard({ cookie: t.Cookie({ auth: t.Optional(t.String()) }) })
.get("/", () => ({ status: "ok" }))
.get("/health", () => ({ status: "ok" }))
@@ -115,24 +116,30 @@ export const app = new Elysia()
".bladeandbrawn.com" :
undefined
});
}, {
body: t.Object({ password: t.String() }),
cookie: t.Cookie({ auth: t.Optional(t.String()) })
})
}, { body: t.Object({ password: t.String() }) })
// CALCULATOR
.post("/calculate", async ({ body }) => {
return { levels: levelCalculator.calculate(body.player, body.activityPerformances) };
}, {
body: t.Object({
player: PlayerSchema,
activityPerformances: t.Array(ActivityPerformanceSchema)
}),
})
.group("/calculator",
(app) => app
.post("/calculate", async ({ body }) => {
return { levels: levelCalculator.calculate(body.player, body.activityPerformances) };
}, {
body: t.Object({
player: PlayerSchema,
activityPerformances: t.Array(ActivityPerformanceSchema)
}),
})
.resolve(async ({ jwt, cookie: { auth } }) => {
const token = auth.value && await jwt.verify(auth.value);
if (!token || !token.sessionId) throw status(401, "Unauthorized");
return { sessionId: token.sessionId.toString() };
})
.post("/config", () => { })
.get("/config", () => { })
)
// COMMERCE
.group("/products",
{ cookie: t.Cookie({ auth: t.Optional(t.String()) }) },
(app) => app
.resolve(async ({ jwt, cookie: { auth } }) => {
const token = auth.value && await jwt.verify(auth.value);