- überflüssiger fetch auf /CPL?KTR... in Development entfernt - Fehler-Alert durch 404-Seite bei Embedded-Link im Dev gefixt - Referenzkurve wird jetzt in Dev nur lokal gespeichert und per API aktualisiert
34 lines
836 B
TypeScript
34 lines
836 B
TypeScript
// /pages/api/cpl/updateTdrReferenceCurveAPIHandler.ts
|
|
import { NextApiRequest, NextApiResponse } from "next";
|
|
import path from "path";
|
|
import { promises as fs } from "fs";
|
|
|
|
export default async function handler(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse
|
|
) {
|
|
if (req.method !== "POST") {
|
|
return res.status(405).json({ error: "Method not allowed" });
|
|
}
|
|
|
|
const { slot, data } = req.body;
|
|
|
|
if (!slot || !data) {
|
|
return res.status(400).json({ error: "Missing slot or data" });
|
|
}
|
|
|
|
const filePath = path.join(
|
|
process.cwd(),
|
|
"apiMockData",
|
|
"tdr-reference-curves",
|
|
`slot${slot}.json`
|
|
);
|
|
|
|
try {
|
|
await fs.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
|
|
res.status(200).json({ success: true });
|
|
} catch (error) {
|
|
res.status(500).json({ error: "Failed to save file" });
|
|
}
|
|
}
|