running schema mutations in safe proxy and revert to previous on error

This commit is contained in:
dswbx
2025-02-12 09:01:56 +01:00
parent 4dde67ca21
commit c8fa704e32
5 changed files with 243 additions and 67 deletions

View File

@@ -1,10 +1,7 @@
import { Exception, isDebug } from "core";
import { Exception } from "core";
import { type Static, StringEnum, Type } from "core/utils";
import { Hono } from "hono";
import { cors } from "hono/cors";
import { timing } from "hono/timing";
import { Module } from "modules/Module";
import * as SystemPermissions from "modules/permissions";
const serverMethods = ["GET", "POST", "PATCH", "PUT", "DELETE"];
export const serverConfigSchema = Type.Object(

View File

@@ -256,17 +256,15 @@ export class SystemController extends Controller {
tb(
"query",
Type.Object({
sync: Type.Optional(booleanLike),
drop: Type.Optional(booleanLike),
save: Type.Optional(booleanLike)
sync: Type.Optional(booleanLike)
})
),
async (c) => {
const { sync, drop, save } = c.req.valid("query") as Record<string, boolean>;
const { sync } = c.req.valid("query") as Record<string, boolean>;
this.ctx.guard.throwUnlessGranted(SystemPermissions.build);
await this.app.build({ sync, drop, save });
return c.json({ success: true, options: { sync, drop, save } });
await this.app.build({ sync });
return c.json({ success: true, options: { sync } });
}
);