Setting up calculator config management
This commit is contained in:
@@ -20,12 +20,27 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||
// INDEX: ONE_ACTIVE_PRODUCT_SYNC
|
||||
await db.schema.createIndex("idx_one_active_product_sync")
|
||||
.on("product_syncs")
|
||||
.unique()
|
||||
.column("ended_at")
|
||||
.unique()
|
||||
.where(sql.ref("started_at"), "is not", null)
|
||||
.where("ended_at", "is", null)
|
||||
.nullsNotDistinct()
|
||||
.execute();
|
||||
|
||||
// TABLE: CALCULATOR_CONFIGS
|
||||
await db.schema.createTable("calculator_configs")
|
||||
.$call(addDefaultColumns)
|
||||
.addColumn("parameters", "jsonb", (cb) => cb.notNull())
|
||||
.addColumn("is_selected", "boolean", (cb) => cb.notNull())
|
||||
.execute();
|
||||
|
||||
// INDEX: ONE_SELECTED_CALCULATOR_CONFIG
|
||||
await db.schema.createIndex("idx_one_selected_calculator_config")
|
||||
.on("calculator_configs")
|
||||
.column("is_selected")
|
||||
.unique()
|
||||
.where("is_selected", "=", true)
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
@@ -34,4 +49,10 @@ export async function down(db: Kysely<any>): Promise<void> {
|
||||
|
||||
// INDEX: ONE_ACTIVE_PRODUCT_SYNC
|
||||
await db.schema.dropIndex("idx_one_active_product_sync").ifExists().execute();
|
||||
|
||||
// TABLE: CALCULATOR_CONFIGS
|
||||
await db.schema.dropTable("calculator_configs").ifExists().execute()
|
||||
|
||||
// INDEX: ONE_SELECTED_CALCULATOR_CONFIG
|
||||
await db.schema.dropIndex("idx_one_selected_calculator_config").ifExists().execute();
|
||||
}
|
||||
|
||||
+12
-5
@@ -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,12 +116,11 @@ 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
|
||||
.group("/calculator",
|
||||
(app) => app
|
||||
.post("/calculate", async ({ body }) => {
|
||||
return { levels: levelCalculator.calculate(body.player, body.activityPerformances) };
|
||||
}, {
|
||||
@@ -129,10 +129,17 @@ export const app = new Elysia()
|
||||
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);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export class CalculatorService {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user