feat(F-048): completed feature

This commit is contained in:
chattie
2026-08-19 07:17:14 +02:00
parent 8ee1938af9
commit 835ab66eda
187 changed files with 12361 additions and 1065 deletions

View File

@@ -1,6 +1,8 @@
import type { FastifyInstance } from 'fastify';
import type { FastifySchema } from 'fastify';
import type { Authenticate } from '../../../shared/auth.js';
import { requireRole } from '../../../shared/auth.js';
import { errorSchema } from '../../../shared/swagger.js';
import { CacheService } from '../application/cache-service.js';
export interface CacheRoutesDeps {
@@ -12,13 +14,23 @@ export async function registerCacheRoutes(
app: FastifyInstance,
deps: CacheRoutesDeps,
): Promise<void> {
app.get('/cache/contracts', async (request, reply) => {
const contractsSchema: FastifySchema = {
tags: ['Admin'],
summary: 'List cache contracts (admin)',
response: { 401: errorSchema, 403: errorSchema },
};
app.get('/cache/contracts', { schema: contractsSchema }, async (request, reply) => {
const user = await deps.authenticate(request);
requireRole(user, 'admin');
return reply.send({ items: deps.cache.listContracts() });
});
app.get('/cache/metrics', async (request, reply) => {
const cacheMetricsSchema: FastifySchema = {
tags: ['Admin'],
summary: 'Cache metrics',
response: { 401: errorSchema },
};
app.get('/cache/metrics', { schema: cacheMetricsSchema }, async (request, reply) => {
await deps.authenticate(request);
return reply.send(deps.cache.metrics());
});