import type { FastifyInstance } from 'fastify'; import type { Sql } from '../db.js'; import type { Config } from '../config.js'; import { getProviderSnapshot, clearProviderSnapshotCache } from '../services/provider-snapshot.js'; export function registerProviderRoutes(app: FastifyInstance, sql: Sql, config: Config): void { app.get<{ Querystring: { cwd?: string } }>('/api/providers/snapshot', async (req, _reply) => { const cwd = req.query.cwd; return getProviderSnapshot(sql, config, cwd); }); app.post('/api/providers/refresh', async (_req, _reply) => { clearProviderSnapshotCache(); const entries = await getProviderSnapshot(sql, config, undefined, true); return { refreshed: entries.length }; }); }