feat: initial commit web-cad-neu with docker-compose, frontend and backend

This commit is contained in:
2026-06-26 10:50:24 +02:00
commit 4ec76fe406
102 changed files with 25722 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
/**
* Layers Routes CRUD for layers
*/
import type { FastifyInstance } from 'fastify';
import type { DatabaseInterface, DBLayer } from '../database/DatabaseInterface.js';
export function registerLayerRoutes(fastify: FastifyInstance, db: DatabaseInterface) {
// List layers for a drawing
fastify.get('/api/drawings/:drawingId/layers', async (request) => {
const { drawingId } = request.params as { drawingId: string };
return db.listLayers(drawingId);
});
// Create layer
fastify.post('/api/drawings/:drawingId/layers', async (request, reply) => {
const { drawingId } = request.params as { drawingId: string };
const body = request.body as Partial<DBLayer>;
return reply.code(201).send(db.createLayer({ ...body, drawing_id: drawingId }));
});
// Update layer
fastify.patch('/api/layers/:id', async (request, reply) => {
const { id } = request.params as { id: string };
const body = request.body as Partial<DBLayer>;
const updated = db.updateLayer(id, body);
if (!updated) return reply.code(404).send({ error: 'Layer not found' });
return updated;
});
// Delete layer
fastify.delete('/api/layers/:id', async (request, reply) => {
const { id } = request.params as { id: string };
const ok = db.deleteLayer(id);
if (!ok) return reply.code(404).send({ error: 'Layer not found' });
return reply.code(204).send();
});
}