import type { FastifyInstance } from "fastify"; import * as syncService from "../services/sync-service.js"; export async function syncRoutes(app: FastifyInstance) { app.post("/sync", async (request) => { const jobId = await syncService.syncAll( request.server.db, request.server.cf, ); return { job_id: jobId }; }); app.post("/domains/:id/sync", async (request) => { const { id } = request.params as { id: string }; const result = await syncService.syncDomain( request.server.db, request.server.cf, Number(id), ); return { job_id: result.jobId, changes: result.changes }; }); app.get("/sync/jobs/:id", async (request) => { const { id } = request.params as { id: string }; return syncService.getJob(request.server.db, id); }); }