mirror of
https://github.com/bknd-io/bknd/
synced 2026-08-03 00:26:01 +00:00
experimenting with config history
This commit is contained in:
@@ -32,6 +32,7 @@ import { getVersion } from "core/env";
|
||||
import type { Module } from "modules/Module";
|
||||
import { getSystemMcp } from "modules/mcp/system-mcp";
|
||||
import type { DbModuleManager } from "modules/db/DbModuleManager";
|
||||
import type { Repository } from "data/entities";
|
||||
|
||||
export type ConfigUpdate<Key extends ModuleKey = ModuleKey> = {
|
||||
success: true;
|
||||
@@ -129,6 +130,25 @@ export class SystemController extends Controller {
|
||||
},
|
||||
);
|
||||
|
||||
hono.get("/history", async (c) => {
|
||||
// @ts-expect-error "repo" is private
|
||||
const repo = manager.repo() as Repository;
|
||||
const { data } = await repo.findMany({
|
||||
where: { type: "diff", version: manager.version() },
|
||||
sort: { by: "id", dir: "desc" },
|
||||
});
|
||||
return c.json(data);
|
||||
});
|
||||
|
||||
hono.get("/history/:id", async (c) => {
|
||||
// @ts-expect-error "repo" is private
|
||||
const repo = manager.repo() as Repository;
|
||||
const { data } = await repo.findId(c.req.param("id"), {
|
||||
where: { type: "diff", version: manager.version() },
|
||||
});
|
||||
return c.json(data);
|
||||
});
|
||||
|
||||
async function handleConfigUpdateResponse(
|
||||
c: Context<any>,
|
||||
cb: () => Promise<ConfigUpdate>,
|
||||
|
||||
Reference in New Issue
Block a user