Files
cloudflare-domain-manager/apps/api/src/routes/sync.ts
T
Denozordec d11414666f
Build, Test, and Push CFDM Docker Image / test (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / build-and-push (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / create-release (push) Has been cancelled
Build, Test, and Push CFDM Docker Image / update-wiki (push) Has been cancelled
Refactor project to transition from Rust backend to Node.js with Fastify; update Dockerfile and Docker configurations for new build process; enhance local development instructions in CONTRIBUTING.md; implement health checks in Docker Compose; update pnpm-lock.yaml with new dependencies for API and shared packages; revise README.md to reflect new stack and development setup.
2026-06-19 12:06:32 +07:00

28 lines
809 B
TypeScript

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);
});
}