Organize and restructure controllers

This commit is contained in:
Dominic Ferrando
2026-10-04 00:41:02 -04:00
parent 3ef0c9e88f
commit 09ac3bfd93
13 changed files with 805 additions and 707 deletions
+54
View File
@@ -0,0 +1,54 @@
import Elysia, { t } from "elysia";
import { StandardsParamsSchema } from "@blade-and-brawn/calculator";
import { authPlugin } from "../plugins/auth";
import { s } from "../services";
import { BigIntIdSchema } from "../util/models";
const StandardsController = new Elysia({ prefix: "/standards" })
.use(authPlugin)
.group("/configs", { authAdmin: true }, (app) => app
.post("/", async ({ body: { name, datasetId, params } }) => {
return await s.Standards.Configs.create(name, datasetId, params);
}, {
body: t.Object({ name: t.String(), datasetId: BigIntIdSchema, params: StandardsParamsSchema })
})
.get("/", async () => {
return await s.Standards.Configs.list();
})
.group("/:id", (app) => app
.get("/", async ({ params: { id } }) => {
return await s.Standards.Configs.get(id);
}, {
params: t.Object({ id: BigIntIdSchema })
})
.put("/", async ({ params: { id }, body: { name, datasetId, params: parameters } }) => {
await s.Standards.Configs.update(id, name, datasetId, parameters);
}, {
params: t.Object({ id: BigIntIdSchema }),
body: t.Object({ name: t.String(), datasetId: BigIntIdSchema, params: StandardsParamsSchema })
})
.delete("/", async ({ params: { id } }) => {
await s.Standards.Configs.delete(id);
}, { params: t.Object({ id: BigIntIdSchema }) })
)
)
.group("/datasets", { authAdmin: true }, (app) => app
.get("/", async () => {
return await s.Standards.Datasets.list();
})
.group("/:id", (app) => app
.get("/", async ({ params: { id } }) => {
return await s.Standards.Datasets.get(id);
}, {
params: t.Object({ id: BigIntIdSchema })
})
.patch("/", async ({ params: { id }, body: { name } }) => {
await s.Standards.Datasets.update(id, name);
}, {
params: t.Object({ id: BigIntIdSchema }),
body: t.Object({ name: t.String() })
})
)
);
export default StandardsController;