2b684da9cd
- 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>
25 lines
964 B
TypeScript
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 });
|
|
});
|