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>
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { Router, Request, Response, NextFunction } from 'express';
|
|
import * as moduleService from '../services/moduleService';
|
|
import { ok } from '../types/index';
|
|
|
|
export const modulesRouter = Router();
|
|
|
|
modulesRouter.put('/:id', async (req: Request, res: Response, next: NextFunction) => {
|
|
try {
|
|
const { name, uPosition, uSize, manufacturer, model, ipAddress, notes } = req.body as {
|
|
name?: string;
|
|
uPosition?: number;
|
|
uSize?: number;
|
|
manufacturer?: string;
|
|
model?: string;
|
|
ipAddress?: string;
|
|
notes?: string;
|
|
};
|
|
res.json(
|
|
ok(
|
|
await moduleService.updateModule(req.params.id, {
|
|
name,
|
|
uPosition,
|
|
uSize,
|
|
manufacturer,
|
|
model,
|
|
ipAddress,
|
|
notes,
|
|
})
|
|
)
|
|
);
|
|
} catch (e) {
|
|
next(e);
|
|
}
|
|
});
|
|
|
|
modulesRouter.delete('/:id', async (req: Request, res: Response, next: NextFunction) => {
|
|
try {
|
|
await moduleService.deleteModule(req.params.id);
|
|
res.json(ok(null));
|
|
} catch (e) {
|
|
next(e);
|
|
}
|
|
});
|
|
|
|
modulesRouter.get('/:id/ports', async (req: Request, res: Response, next: NextFunction) => {
|
|
try {
|
|
res.json(ok(await moduleService.getModulePorts(req.params.id)));
|
|
} catch (e) {
|
|
next(e);
|
|
}
|
|
});
|