Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x | import { Hono } from "hono";
import { AstSchemaEditor } from "./ast-schema-editor";
import { HonoEnv } from "./types";
export function createSchemaEditorRoutes(collectionsDir: string): Hono<HonoEnv> {
const router = new Hono<HonoEnv>();
const editor = new AstSchemaEditor(collectionsDir);
router.post("/property/save", async (c) => {
const body = await c.req.json();
const { collectionId, propertyKey, propertyConfig } = body;
await editor.saveProperty(collectionId, propertyKey, propertyConfig);
return c.json({ success: true });
});
router.post("/property/delete", async (c) => {
const body = await c.req.json();
const { collectionId, propertyKey } = body;
await editor.deleteProperty(collectionId, propertyKey);
return c.json({ success: true });
});
router.post("/collection/save", async (c) => {
const body = await c.req.json();
const { collectionId, collectionData } = body;
await editor.saveCollection(collectionId, collectionData);
return c.json({ success: true });
});
router.post("/collection/delete", async (c) => {
const body = await c.req.json();
const { collectionId } = body;
await editor.deleteCollection(collectionId);
return c.json({ success: true });
});
return router;
}
|