18 lines
654 B
TypeScript
18 lines
654 B
TypeScript
import type { Request, Response } from "express";
|
|
import { circuitNumberingService } from "../composition/circuit-numbering-service.js";
|
|
|
|
export async function getNextCircuitIdentifier(req: Request, res: Response) {
|
|
const { sectionId } = req.params;
|
|
if (typeof sectionId !== "string") {
|
|
return res.status(400).json({ error: "Invalid sectionId" });
|
|
}
|
|
try {
|
|
const nextIdentifier =
|
|
await circuitNumberingService.getNextIdentifier(sectionId);
|
|
return res.json({ sectionId, nextIdentifier });
|
|
} catch (error) {
|
|
return res.status(400).json({ error: error instanceof Error ? error.message : "Failed to get identifier." });
|
|
}
|
|
}
|
|
|