14 lines
780 B
TypeScript
14 lines
780 B
TypeScript
import type { FastifyPluginAsyncZod } from "@fastify/type-provider-zod"
|
|
import { defaultSidebarCountsDependencies, readSidebarCounts, type SidebarCountsDependencies } from "../services/sidebar-counts.js"
|
|
export { defaultSidebarCountsDependencies } from "../services/sidebar-counts.js"
|
|
|
|
export function createSidebarCountsRoutes(deps: SidebarCountsDependencies = defaultSidebarCountsDependencies): FastifyPluginAsyncZod {
|
|
return async app => {
|
|
app.get("/sidebar-counts", async (_req, reply) => {
|
|
try { return reply.header("Cache-Control", "no-store").send(await readSidebarCounts(deps)) }
|
|
catch { return reply.status(500).send({ error: "Основные счётчики не подтверждены" }) }
|
|
})
|
|
}
|
|
}
|
|
export default createSidebarCountsRoutes()
|