diff --git a/apps/api/src/server.ts b/apps/api/src/server.ts index 38300c8..241c2d2 100644 --- a/apps/api/src/server.ts +++ b/apps/api/src/server.ts @@ -80,7 +80,6 @@ export const app = new Elysia() /^https?:\/\/([a-z0-9-]+\.)?bladeandbrawn\.com$/i, // testing /^https?:\/\/([a-z0-9-]+\.)?bladeandbrawn\.webflow\.io$/i, - /^https?:\/\/([a-z0-9-]+\.)?bladeandbrawn-test\.webflow\.io$/i, // development "http://localhost:5173", ], @@ -261,15 +260,16 @@ export const app = new Elysia() }), }) // Authenticated - .guard({ authAdmin: true }) - .get("/standards/config", async () => { - return await s.Calculator.Standards.Config.get(); - }) - .post("/standards/config/switch", async ({ body: { standardsConfigId } }) => { - await s.Calculator.Standards.Config.switch(standardsConfigId); - }, { - body: t.Object({ standardsConfigId: t.String() }) - }) + .guard({ authAdmin: true }, (app) => app + .get("/standards/config", async () => { + return await s.Calculator.Standards.Config.get(); + }) + .post("/standards/config/switch", async ({ body: { standardsConfigId } }) => { + await s.Calculator.Standards.Config.switch(standardsConfigId); + }, { + body: t.Object({ standardsConfigId: t.String() }) + }) + ) ) .group("/standards", { authAdmin: true }, (app) => app .post("/configs", async ({ body: { name, datasetId, params } }) => { @@ -457,20 +457,22 @@ export const app = new Elysia() }, { params: t.Object({ id: t.String() }) }) - .guard({ authUser: true }) - .get("/me/stats", async ({ accountId }) => { - const stats = await s.Accounts.stats(accountId); - if (!stats) throw new NotFoundError("Account stats not found"); - return stats; - }) - .guard({ authAdmin: true }) - .get("/:id", async ({ params: { id } }) => { - const account = await s.Accounts.get(id); - if (!account) throw new NotFoundError("Account not found"); - return account; - }, { - params: t.Object({ id: t.String() }) - }) + .guard({ authUser: true }, (app) => app + .get("/me/stats", async ({ accountId }) => { + const stats = await s.Accounts.stats(accountId); + if (!stats) throw new NotFoundError("Account stats not found"); + return stats; + }) + ) + .guard({ authAdmin: true }, (app) => app + .get("/:id", async ({ params: { id } }) => { + const account = await s.Accounts.get(id); + if (!account) throw new NotFoundError("Account not found"); + return account; + }, { + params: t.Object({ id: t.String() }) + }) + ) ) // WEBHOOKS