feat(dm): new endpoint to get the forecast data

This commit is contained in:
2025-11-21 15:37:22 -06:00
parent b23bb0db31
commit a96b85bc53
3 changed files with 43 additions and 1 deletions

View File

@@ -1,6 +1,9 @@
import type { Request, Response } from "express";
import { Router } from "express";
import z from "zod";
import z, { success } from "zod";
import { db } from "../../../../pkg/db/db.js";
import { forecastData } from "../../../../pkg/db/schema/forecastEDIData.js";
import { tryCatch } from "../../../../pkg/utils/tryCatch.js";
import { forecastEdiData } from "../../controller/demandManagement/forecastEDIData.js";
export const Preprint = z.object({
@@ -21,4 +24,19 @@ router.post("/forecastData", async (req: Request, res: Response) => {
res.status(200).json({ success: true, message: "Forecast Data", data: [] });
});
// quick fix for getting the data
router.get("/forecastData", async (req: Request, res: Response) => {
const { data, error } = await tryCatch(db.select().from(forecastData));
if (error) {
return res.status(400).json({
success: false,
message: "Error getting forecast data",
error: error,
});
}
res.status(200).json({ success: true, message: "Forecast Data", data: data });
});
export default router;