Nextcloud, NetBox and n8n integrations

Three read-only integrations, each with a monitoring page, alerts, maintenance
silencing and held-when-unreadable handling.

Nextcloud: database needing upgrade (critical), maintenance mode, and the data
disk running low; users, files and app updates with an admin app password.
NetBox: no background worker running, counts, and a list of the servers this
app manages that have no address in NetBox (a list, not an alert).
n8n: an active workflow whose last run failed, clearing when it next succeeds.

Disk messages for Immich, Paperless and Nextcloud now use the same units as
the pages that show them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-24 23:13:13 +02:00
1 parent a16996d975
commit 4ff0b44943
46 files changed
+10137 -10

No files matched your search

+12
View File
@@ -34,6 +34,9 @@ import { forgetAuthentik, syncAuthentik } from "../services/authentikSync.js";
import { forgetPrometheus, syncPrometheus } from "../services/prometheusSync.js";
import { forgetImmich, syncImmich } from "../services/immichSync.js";
import { forgetPaperless, syncPaperless } from "../services/paperlessSync.js";
import { forgetN8n, syncN8n } from "../services/n8nSync.js";
import { forgetNetBox, syncNetBox } from "../services/netboxSync.js";
import { forgetNextcloud, syncNextcloud } from "../services/nextcloudSync.js";
import { invalidateAlertsCache } from "../services/alerts.js";
import { getSettings, updateSettings } from "../services/settingsStore.js";
import { asyncHandler } from "../utils/asyncHandler.js";
@@ -141,6 +144,9 @@ integrationsRouter.post("/", requireRole("admin"), asyncHandler(async (req, res)
if (type === "prometheus") void syncPrometheus(created.id).then(() => invalidateAlertsCache());
if (type === "immich") void syncImmich(created.id).then(() => invalidateAlertsCache());
if (type === "paperless") void syncPaperless(created.id).then(() => invalidateAlertsCache());
if (type === "n8n") void syncN8n(created.id).then(() => invalidateAlertsCache());
if (type === "netbox") void syncNetBox(created.id).then(() => invalidateAlertsCache());
if (type === "nextcloud") void syncNextcloud(created.id).then(() => invalidateAlertsCache());
res.status(201).json({
integration: {
@@ -249,6 +255,9 @@ integrationsRouter.patch("/:id", requireRole("admin"), asyncHandler(async (req,
if (updated.type === "prometheus" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncPrometheus(updated.id).then(() => invalidateAlertsCache());
if (updated.type === "immich" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncImmich(updated.id).then(() => invalidateAlertsCache());
if (updated.type === "paperless" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncPaperless(updated.id).then(() => invalidateAlertsCache());
if (updated.type === "n8n" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncN8n(updated.id).then(() => invalidateAlertsCache());
if (updated.type === "netbox" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncNetBox(updated.id).then(() => invalidateAlertsCache());
if (updated.type === "nextcloud" && updated.enabled && (parsed.data.config || parsed.data.enabled === true)) void syncNextcloud(updated.id).then(() => invalidateAlertsCache());
res.json({
integration: {
@@ -333,6 +342,9 @@ integrationsRouter.delete("/:id", requireRole("admin"), asyncHandler(async (req,
if (existing.type === "prometheus") await forgetPrometheus(id);
if (existing.type === "immich") await forgetImmich(id);
if (existing.type === "paperless") await forgetPaperless(id);
if (existing.type === "n8n") await forgetN8n(id);
if (existing.type === "netbox") await forgetNetBox(id);
if (existing.type === "nextcloud") await forgetNextcloud(id);
await db.delete(integrations).where(eq(integrations.id, id));
if (existing.credentialId) {
await db.delete(integrationCredentials).where(eq(integrationCredentials.id, existing.credentialId));
+37
View File
@@ -0,0 +1,37 @@
import { Router } from "express";
import { eq } from "drizzle-orm";
import { db } from "../db/client.js";
import { integrations, n8nState } from "../db/schema.js";
import { requireAuth } from "../auth/middleware.js";
import { isN8nFresh, n8nProblems, n8nSyncStatuses, workflowsOf } from "../services/n8nSync.js";
import { asyncHandler } from "../utils/asyncHandler.js";
export const n8nRouter = Router();
n8nRouter.use(requireAuth);
/** Every n8n, how it is, from what the last read stored: its workflows with their last runs, and what is wrong. Everyone signed in can see it, like the other pages made of stored readings. */
n8nRouter.get("/", asyncHandler(async (_req, res) => {
const [rows, states, statuses] = await Promise.all([
db.select({ id: integrations.id, name: integrations.name, enabled: integrations.enabled }).from(integrations).where(eq(integrations.type, "n8n")).orderBy(integrations.name),
db.select().from(n8nState),
n8nSyncStatuses(),
]);
const byId = new Map(states.map((s) => [s.integrationId, s]));
const now = new Date();
res.json({
n8ns: rows.map((r) => {
const state = byId.get(r.id) ?? null;
const status = statuses[r.id] ?? null;
const fresh = isN8nFresh(status ?? undefined, now.getTime());
return {
id: r.id,
name: r.name,
enabled: r.enabled,
status,
fresh,
state: state ? { workflows: workflowsOf(state), executionsKnown: state.executionsKnown, updatedAt: state.updatedAt } : null,
problems: state && fresh ? n8nProblems(r.id, r.name, state, now) : [],
};
}),
});
}));
+68
View File
@@ -0,0 +1,68 @@
import { Router } from "express";
import { eq } from "drizzle-orm";
import { db } from "../db/client.js";
import { integrations, netboxState, servers } from "../db/schema.js";
import { requireAuth } from "../auth/middleware.js";
import { makeExclusion } from "../services/consistency.js";
import { ipsOf, isNetBoxFresh, netboxProblems, netboxSyncStatuses, serversMissingFromNetBox } from "../services/netboxSync.js";
import { getSettings } from "../services/settingsStore.js";
import { asyncHandler } from "../utils/asyncHandler.js";
export const netboxRouter = Router();
netboxRouter.use(requireAuth);
const parseIps = (stored: string | null): string[] => {
if (!stored) return [];
try {
const v = JSON.parse(stored);
return Array.isArray(v) ? v.filter((x): x is string => typeof x === "string") : [];
} catch {
return [];
}
};
/** Every NetBox, how it is, from what the last read stored: its workers, the counts, and which of the servers this app manages have no address in it. Everyone signed in can see it. */
netboxRouter.get("/", asyncHandler(async (_req, res) => {
const [rows, states, statuses, serverRows, settings] = await Promise.all([
db.select({ id: integrations.id, name: integrations.name, enabled: integrations.enabled }).from(integrations).where(eq(integrations.type, "netbox")).orderBy(integrations.name),
db.select().from(netboxState),
netboxSyncStatuses(),
db.select({ id: servers.id, name: servers.name, ips: servers.ipAddresses }).from(servers),
getSettings(),
]);
const byId = new Map(states.map((s) => [s.integrationId, s]));
const serverList = serverRows.map((s) => ({ id: s.id, name: s.name, ips: parseIps(s.ips) }));
const excluded = makeExclusion(settings.consistency.excludedRanges);
const now = Date.now();
res.json({
netboxes: rows.map((r) => {
const state = byId.get(r.id) ?? null;
const status = statuses[r.id] ?? null;
const fresh = isNetBoxFresh(status ?? undefined, now);
const ips = state ? ipsOf(state) : null;
return {
id: r.id,
name: r.name,
enabled: r.enabled,
status,
fresh,
state: state
? {
version: state.version,
workersRunning: state.workersRunning,
devices: state.devices,
virtualMachines: state.virtualMachines,
prefixes: state.prefixes,
ipAddresses: state.ipAddresses,
/** Null when NetBox's addresses could not be listed, so nothing can be said about what is missing from it. */
missing: ips ? serversMissingFromNetBox(serverList, ips, excluded) : null,
/** More addresses than were kept: what is missing may be in the part that was not read. */
truncated: ips !== null && state.ipAddresses !== null && state.ipAddresses > ips.length,
updatedAt: state.updatedAt,
}
: null,
problems: state && fresh ? netboxProblems(r.id, r.name, state) : [],
};
}),
});
}));
+50
View File
@@ -0,0 +1,50 @@
import { Router } from "express";
import { eq } from "drizzle-orm";
import { db } from "../db/client.js";
import { integrations, nextcloudState } from "../db/schema.js";
import { requireAuth } from "../auth/middleware.js";
import { isNextcloudFresh, nextcloudProblems, nextcloudSyncStatuses } from "../services/nextcloudSync.js";
import { asyncHandler } from "../utils/asyncHandler.js";
export const nextcloudRouter = Router();
nextcloudRouter.use(requireAuth);
/** Every Nextcloud, how it is, from what the last read stored: maintenance mode, the data disk, the users, the app updates and what is wrong. Everyone signed in can see it, like the other pages made of stored readings. */
nextcloudRouter.get("/", asyncHandler(async (_req, res) => {
const [rows, states, statuses] = await Promise.all([
db.select({ id: integrations.id, name: integrations.name, enabled: integrations.enabled }).from(integrations).where(eq(integrations.type, "nextcloud")).orderBy(integrations.name),
db.select().from(nextcloudState),
nextcloudSyncStatuses(),
]);
const byId = new Map(states.map((s) => [s.integrationId, s]));
const now = Date.now();
res.json({
nextclouds: rows.map((r) => {
const state = byId.get(r.id) ?? null;
const status = statuses[r.id] ?? null;
const fresh = isNextcloudFresh(status ?? undefined, now);
return {
id: r.id,
name: r.name,
enabled: r.enabled,
status,
fresh,
state: state
? {
version: state.version,
maintenance: state.maintenance,
needsUpgrade: state.needsUpgrade,
detail: state.detail,
freeBytes: state.freeBytes,
users: state.users,
files: state.files,
active24h: state.active24h,
appUpdates: state.appUpdates,
updatedAt: state.updatedAt,
}
: null,
problems: state && fresh ? nextcloudProblems(r.id, r.name, state) : [],
};
}),
});
}));