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.
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
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
This commit is contained in:
1 parent
0a0a1a92f1
commit
d11414666f
2065 files changed
+15782
-16699
No files matched your search
@@ -0,0 +1,75 @@
|
||||
import type { FastifyInstance } from "fastify";
|
||||
import { z } from "zod";
|
||||
import * as domainService from "../services/domain-service.js";
|
||||
|
||||
export async function domainRoutes(app: FastifyInstance) {
|
||||
const createSchema = z.object({
|
||||
zone_name: z.string(),
|
||||
group_id: z.number().nullable().optional(),
|
||||
});
|
||||
|
||||
const updateSchema = z.object({
|
||||
group_id: z.number().nullable().optional(),
|
||||
status: z.string().optional(),
|
||||
});
|
||||
|
||||
app.get("/domains", async (request) => {
|
||||
const query = request.query as { group_id?: string };
|
||||
const groupId = query.group_id ? Number(query.group_id) : undefined;
|
||||
return domainService.listDomains(request.server.db, groupId);
|
||||
});
|
||||
|
||||
app.post("/domains", async (request) => {
|
||||
const body = createSchema.parse(request.body);
|
||||
return domainService.createDomain(
|
||||
request.server.db,
|
||||
request.server.cf,
|
||||
body.group_id ?? null,
|
||||
body.zone_name,
|
||||
);
|
||||
});
|
||||
|
||||
app.get("/domains/:id", async (request) => {
|
||||
const { id } = request.params as { id: string };
|
||||
return domainService.getDomain(request.server.db, Number(id));
|
||||
});
|
||||
|
||||
app.patch("/domains/:id", async (request) => {
|
||||
const { id } = request.params as { id: string };
|
||||
const body = updateSchema.parse(request.body);
|
||||
const existing = domainService.getDomain(request.server.db, Number(id));
|
||||
return domainService.updateDomain(
|
||||
request.server.db,
|
||||
Number(id),
|
||||
body.group_id !== undefined ? body.group_id : existing.group_id,
|
||||
body.status ?? existing.status,
|
||||
);
|
||||
});
|
||||
|
||||
app.delete("/domains/:id", async (request) => {
|
||||
const { id } = request.params as { id: string };
|
||||
domainService.deleteDomain(request.server.db, Number(id));
|
||||
return { deleted: true };
|
||||
});
|
||||
|
||||
app.post("/domains/:id/import", async (request) => {
|
||||
const { id } = request.params as { id: string };
|
||||
const imported = await domainService.importZoneRecords(
|
||||
request.server.db,
|
||||
request.server.cf,
|
||||
Number(id),
|
||||
);
|
||||
return { imported };
|
||||
});
|
||||
|
||||
app.put("/domains/:id/services", async (request) => {
|
||||
const { id } = request.params as { id: string };
|
||||
const body = z.object({ service_ids: z.array(z.number()) }).parse(request.body);
|
||||
const serviceIds = await domainService.setDomainServices(
|
||||
request.server.db,
|
||||
Number(id),
|
||||
body.service_ids,
|
||||
);
|
||||
return { service_ids: serviceIds };
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user