Complete project scaffold with working auth, REST API, Prisma/SQLite schema, Docker config, and React frontend for both Rack Planner and Service Mapper modules. Both server and client pass TypeScript strict mode with zero errors. Initial migration applied. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34 lines
945 B
TypeScript
34 lines
945 B
TypeScript
import { Router, Request, Response, NextFunction } from 'express';
|
|
import * as mapService from '../services/mapService';
|
|
import { ok } from '../types/index';
|
|
|
|
export const nodesRouter = Router();
|
|
|
|
nodesRouter.put('/:id', async (req: Request, res: Response, next: NextFunction) => {
|
|
try {
|
|
const { label, positionX, positionY, metadata, color, icon, moduleId } = req.body as {
|
|
label?: string;
|
|
positionX?: number;
|
|
positionY?: number;
|
|
metadata?: string;
|
|
color?: string;
|
|
icon?: string;
|
|
moduleId?: string | null;
|
|
};
|
|
res.json(
|
|
ok(await mapService.updateNode(req.params.id, { label, positionX, positionY, metadata, color, icon, moduleId }))
|
|
);
|
|
} catch (e) {
|
|
next(e);
|
|
}
|
|
});
|
|
|
|
nodesRouter.delete('/:id', async (req: Request, res: Response, next: NextFunction) => {
|
|
try {
|
|
await mapService.deleteNode(req.params.id);
|
|
res.json(ok(null));
|
|
} catch (e) {
|
|
next(e);
|
|
}
|
|
});
|