- Remove dead widget.audiobookshelf/navidrome i18n blocks (76 lines) - Simplify audio-stats router (remove duplicated kind casts) - Remove redundant defaultDisplayOptions in audio-stats component - Dedup fetch helpers in uptime-kuma (fetchOkAsync) and paperless-ngx (fetchAuthenticatedAsync) - Simplify navidrome asArray helper and getArtistCountAsync - Simplify uptime-kuma averageUptimePercent and status derivation
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { audiobookshelfRequestHandler } from "@homarr/request-handler/audiobookshelf";
|
|
import { navidromeRequestHandler } from "@homarr/request-handler/navidrome";
|
|
|
|
import { createOneIntegrationMiddleware } from "../../middlewares/integration";
|
|
import { createTRPCRouter, publicProcedure } from "../../trpc";
|
|
|
|
export const audioStatsRouter = createTRPCRouter({
|
|
getStats: publicProcedure
|
|
.concat(createOneIntegrationMiddleware("query", "navidrome", "audiobookshelf"))
|
|
.query(async ({ ctx }) => {
|
|
const { kind } = ctx.integration;
|
|
|
|
const fetchByKind = {
|
|
navidrome: async () => {
|
|
const handler = navidromeRequestHandler.handler({ ...ctx.integration, kind: "navidrome" as const }, {});
|
|
return (await handler.getCachedOrUpdatedDataAsync({ forceUpdate: false })).data;
|
|
},
|
|
audiobookshelf: async () => {
|
|
const handler = audiobookshelfRequestHandler.handler({ ...ctx.integration, kind: "audiobookshelf" as const }, {});
|
|
return (await handler.getCachedOrUpdatedDataAsync({ forceUpdate: false })).data;
|
|
},
|
|
} as const;
|
|
|
|
return { kind, data: await fetchByKind[kind]() };
|
|
}),
|
|
});
|