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
28 lines
809 B
TypeScript
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);
|
|
});
|
|
}
|