All files / src/routes stats.ts

53.84% Statements 7/13
100% Branches 1/1
100% Functions 1/1
53.84% Lines 7/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 191x         1x 26x 26x   26x             26x 26x  
import type { FastifyPluginAsync } from "fastify";
import type { AppConfig } from "../config.js";
import { proxyJsonRequest } from "../lib/http-client.js";
 
/** Публичная статистика каталога (открытые данные) — без авторизации. */
export const statsRoutes: FastifyPluginAsync<{ config: AppConfig }> = async (app, opts) => {
  const { config } = opts;
  const svc = { "x-service-token": config.serviceToken };
 
  app.get("/stats", async () =>
    proxyJsonRequest<unknown>({
      method: "GET",
      url: `${config.catalogServiceUrl}/stats`,
      headers: svc,
      timeoutMs: config.upstreamTimeoutMs,
    }),
  );
};