P1-0: V8 heap cap (HOMARR_MAX_OLD_SPACE_SIZE, default 512MB)
P1-1: Module graph cuts
- Dynamic integration imports (55 static → lazy loaders)
- Conditional DB driver loading (only configured driver loaded)
- Replace jsdom with linkedom for SVG sanitization
- Delete eager widget barrel (55 import * as → 0)
- Extract createRetryableLoader to @homarr/common
P1-2: Enable cacheComponents + restructure root layout
- Suspense boundaries around session-dependent providers
- ColorSchemeScript replaces server-side cookie reads
- Board/manage/auth layouts wrapped in Suspense
P1-3: Cache read paths
- Cache tag registry + invalidation helpers
- Cache invalidation wired into all mutation routers
- Translation deep-merge memoized per locale
P1-4: Prerendered shells + loading.tsx files
P1-5: Shared integration data cache (60s TTL, stale-while-revalidate)
P1-6: Redis-backed Next.js cache handler (@homarr/next-cache-handler)
P1-7: Redis optional (memory channel fallback), TTL on pubSub:last:*,
Redis clients consolidated from 6 to 2
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import { getIntegrationKindsByCategory } from "@homarr/definitions";
|
|
import {
|
|
firewallCpuRequestHandler,
|
|
firewallInterfacesRequestHandler,
|
|
firewallMemoryRequestHandler,
|
|
firewallVersionRequestHandler,
|
|
} from "@homarr/request-handler/firewall";
|
|
|
|
import { createManyIntegrationMiddleware } from "../../middlewares/integration";
|
|
import { integrationQueryKey, settleIntegrationQueries } from "../../settle-integrations";
|
|
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
|
|
|
const firewallMiddleware = createManyIntegrationMiddleware("query", ...getIntegrationKindsByCategory("firewall"));
|
|
|
|
const queryFirewall = <
|
|
THandler extends {
|
|
handler: (integration: any, input: any) => { getDataAsync: () => Promise<{ data: any; timestamp: Date }> };
|
|
},
|
|
>(
|
|
handler: THandler,
|
|
queryKey: string,
|
|
) =>
|
|
publicProcedure.concat(firewallMiddleware).query(async ({ ctx }) =>
|
|
settleIntegrationQueries(
|
|
ctx.integrations,
|
|
async (integration) => {
|
|
const { data, timestamp } = await handler.handler(integration, {}).getDataAsync();
|
|
return {
|
|
integration: { id: integration.id, name: integration.name, kind: integration.kind, updatedAt: timestamp },
|
|
summary: data as Awaited<ReturnType<ReturnType<THandler["handler"]>["getDataAsync"]>>["data"],
|
|
};
|
|
},
|
|
{ queryKey },
|
|
),
|
|
);
|
|
|
|
export const firewallRouter = createTRPCRouter({
|
|
getFirewallCpuStatus: queryFirewall(firewallCpuRequestHandler, integrationQueryKey("firewall", "getFirewallCpuStatus")),
|
|
getFirewallInterfacesStatus: queryFirewall(
|
|
firewallInterfacesRequestHandler,
|
|
integrationQueryKey("firewall", "getFirewallInterfacesStatus"),
|
|
),
|
|
getFirewallVersionStatus: queryFirewall(
|
|
firewallVersionRequestHandler,
|
|
integrationQueryKey("firewall", "getFirewallVersionStatus"),
|
|
),
|
|
getFirewallMemoryStatus: queryFirewall(
|
|
firewallMemoryRequestHandler,
|
|
integrationQueryKey("firewall", "getFirewallMemoryStatus"),
|
|
),
|
|
});
|