prefixed data entity endpoints with /entity

This commit is contained in:
dswbx
2025-02-18 09:12:12 +01:00
parent bd362607ae
commit 3e6d381239
14 changed files with 147 additions and 73 deletions

View File

@@ -142,14 +142,13 @@ export class SystemController extends Controller {
const value = await c.req.json();
const path = c.req.param("path") as string;
const moduleConfig = this.app.mutateConfig(module);
if (moduleConfig.has(path)) {
if (this.app.modules.get(module).schema().has(path)) {
return c.json({ success: false, path, error: "Path already exists" }, { status: 400 });
}
console.log("-- add", module, path, value);
return await handleConfigUpdateResponse(c, async () => {
await moduleConfig.patch(path, value);
await this.app.mutateConfig(module).patch(path, value);
return {
success: true,
module,
@@ -283,6 +282,6 @@ export class SystemController extends Controller {
return c.json(generateOpenAPI(config));
});
return hono;
return hono.all("*", (c) => c.notFound());
}
}

View File

@@ -127,7 +127,7 @@ function dataRoutes(config: ModuleConfigs): { paths: OAS.Document["paths"] } {
const tags = ["data"];
const paths: OAS.PathsObject = {
"/{entity}": {
"/entity/{entity}": {
get: {
summary: "List entities",
parameters: [params.entity],
@@ -148,7 +148,7 @@ function dataRoutes(config: ModuleConfigs): { paths: OAS.Document["paths"] } {
tags
}
},
"/{entity}/{id}": {
"/entity/{entity}/{id}": {
get: {
summary: "Get entity",
parameters: [params.entity, params.entityId],