Setting up calculator config management
This commit is contained in:
+20
-13
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user