Files
system_update/server/routes/settings.ts
T
gilles 2b684da9cd 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>
2026-06-06 07:53:47 +02:00

25 lines
964 B
TypeScript

// 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 });
});