import { Router } from "express"; import { requireAuth } from "../middleware/auth.middleware.js"; import { apiReturn } from "../utils/returnHelper.utils.js"; import { postData } from "./logistics.dm.postData.js"; const r = Router(); r.post("/", requireAuth, async (req, res) => { let posting: any; if (req.body.type !== "forecast" || req.body.type !== "orders") { return apiReturn(res, { success: false, level: "error", module: "dm", subModule: "repost", message: "You must pass over a proper type.", data: [], status: 500, }); } if (req.body.type === "forecast") { posting = await postData( { type: "forecast", endpoint: "/public/v1.0/DemandManagement/DELFOR", data: req.body.data as any, }, req.user, ); } if (req.body.type === "orders") { posting = await postData( { type: "orders", endpoint: "/public/v1.0/DemandManagement/ORDERS", data: req.body.data as any, }, req.user, ); } return apiReturn(res, { success: posting.success, level: posting.success ? "info" : "error", module: "dm", subModule: "repost", message: posting.message, data: [], status: 200, }); }); export default r;