- Start.js (last20Messages) als JS-Mock in /apiMockData/jsMockFiles gespeichert - de.js (digitale Eingänge) in /apiMockData/SERVICE verlagert - Beide werden über eigene API-Endpoints bzw. per Script-Tag aus Development-Verzeichnis geladen - Kein Zugriff mehr über /public notwendig, Verhalten in DEV und PROD identisch
31 lines
649 B
TypeScript
31 lines
649 B
TypeScript
// /pages/api/cpl/tdmData.ts
|
|
|
|
import { NextApiRequest, NextApiResponse } from "next";
|
|
import path from "path";
|
|
import fs from "fs/promises";
|
|
|
|
export default async function handler(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse
|
|
) {
|
|
const { slot } = req.query;
|
|
|
|
if (!slot) {
|
|
return res.status(400).json({ error: "Missing parameter: slot" });
|
|
}
|
|
|
|
const filePath = path.join(
|
|
process.cwd(),
|
|
"apiMockData",
|
|
"TDM",
|
|
`slot${slot}.json`
|
|
);
|
|
|
|
try {
|
|
const data = await fs.readFile(filePath, "utf-8");
|
|
res.status(200).json(JSON.parse(data));
|
|
} catch (error) {
|
|
res.status(404).json({ error: "File not found" });
|
|
}
|
|
}
|