feat(api): profil machine éditable, sonde, et réglages globaux apt-cacher-ng
- machines : updateMachine (PATCH /machines/:id) + POST /machines/:id/probe (sonde synchrone → faits + proposition de correction) ; MachineView expose machineKind/virtualization ; CreateMachineInput accepte aptProxyMode persistent - app_settings (clé/valeur, migration 0006) + service appSettings : défaut apt-cacher-ng (mode + url) ; applyProxyToAllMachines - routes /settings : GET, PUT /apt-proxy, POST /apt-proxy/apply-all Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
// server/routes/machines.ts
|
||||
import { Hono } from "hono";
|
||||
import {
|
||||
listMachines, createMachine, deleteMachine, getMachineRow, getCreds, testConnection,
|
||||
type CreateMachineInput,
|
||||
listMachines, createMachine, deleteMachine, updateMachine, getMachineRow, getCreds, testConnection,
|
||||
type CreateMachineInput, type UpdateMachineInput,
|
||||
} from "../services/machines.js";
|
||||
import { refreshMachine, getLatestSnapshot } from "../services/refresh.js";
|
||||
import { runProbe } from "../services/machineProbe.js";
|
||||
|
||||
export const machinesRoutes = new Hono();
|
||||
|
||||
@@ -43,6 +44,25 @@ machinesRoutes.post("/:id/refresh", async (c) => {
|
||||
}
|
||||
});
|
||||
|
||||
machinesRoutes.patch("/:id", async (c) => {
|
||||
const body = (await c.req.json()) as UpdateMachineInput;
|
||||
try {
|
||||
return c.json(updateMachine(c.req.param("id"), body));
|
||||
} catch (err) {
|
||||
return c.json({ error: (err as Error).message }, 400);
|
||||
}
|
||||
});
|
||||
|
||||
// Sonde synchrone (lecture seule) : renvoie faits + proposition de correction.
|
||||
machinesRoutes.post("/:id/probe", async (c) => {
|
||||
try {
|
||||
const o = await runProbe(c.req.param("id"));
|
||||
return c.json({ probe: o.probe, proposal: o.proposal, changes: o.changes });
|
||||
} catch (err) {
|
||||
return c.json({ error: (err as Error).message }, 400);
|
||||
}
|
||||
});
|
||||
|
||||
machinesRoutes.delete("/:id", (c) => {
|
||||
deleteMachine(c.req.param("id"));
|
||||
return c.json({ ok: true });
|
||||
|
||||
Reference in New Issue
Block a user