feat(api): expose unifiOs widget summary query through tRPC router and request handler
Create unifiOs request handler with 60s cache and stale-on-error fallback, and tRPC router exposing clientApi.widget.unifiOs.summary query. Include minimal widget stub for type system. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
11dd6f44ea
commit
604c6d0855
5 files changed
+60
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import { createIntegrationAsync } from "@homarr/integrations";
|
||||
import type { UnifiOsSummary } from "@homarr/integrations/types";
|
||||
|
||||
import { createIntegrationRequestHandler } from "./lib/integration-request-handler";
|
||||
|
||||
export const unifiOsRequestHandler = createIntegrationRequestHandler<UnifiOsSummary, "unifiOs", Record<string, never>>({
|
||||
async requestAsync(integration, _input) {
|
||||
const integrationInstance = await createIntegrationAsync(integration);
|
||||
return await integrationInstance.getUnifiOsSummaryAsync();
|
||||
},
|
||||
cacheTtlMs: 60 * 1000,
|
||||
// Une console momentanément injoignable doit afficher la dernière valeur connue
|
||||
// plutôt qu'une tuile d'erreur ; le widget signale la péremption.
|
||||
fallbackToStaleOnError: true,
|
||||
staleIfErrorTtlMs: 10 * 60 * 1000,
|
||||
});
|
||||
Reference in new issue
Block a user