feat(dm): new endpoint to get the forecast data
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user