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:
@@ -0,0 +1,24 @@
|
||||
// server/routes/settings.ts
|
||||
import { Hono } from "hono";
|
||||
import { getDefaultAptProxy, setDefaultAptProxy, type DefaultAptProxy } from "../services/appSettings.js";
|
||||
import { applyProxyToAllMachines } from "../services/machines.js";
|
||||
|
||||
export const settingsRoutes = new Hono();
|
||||
|
||||
// Réglages globaux exposés à l'UI.
|
||||
settingsRoutes.get("/", (c) => c.json({ defaultAptProxy: getDefaultAptProxy() }));
|
||||
|
||||
// Définit le proxy APT par défaut (apt-cacher-ng).
|
||||
settingsRoutes.put("/apt-proxy", async (c) => {
|
||||
const body = (await c.req.json()) as DefaultAptProxy;
|
||||
const mode = body.mode ?? "direct";
|
||||
const url = (body.url ?? "").trim() || null;
|
||||
return c.json(setDefaultAptProxy({ mode, url }));
|
||||
});
|
||||
|
||||
// Applique le proxy par défaut à toutes les machines existantes.
|
||||
settingsRoutes.post("/apt-proxy/apply-all", (c) => {
|
||||
const { mode, url } = getDefaultAptProxy();
|
||||
const updated = applyProxyToAllMachines(mode, url);
|
||||
return c.json({ ok: true, updated });
|
||||
});
|
||||
Reference in New Issue
Block a user