Files
lst_v3/backend/logistics/logistics.dm.repost.route.ts
Blake Matthes 9a0bb18c5b
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 2m34s
feat(dm): added in a repost incase we wanted do this instead of reuploading the file
ref #31
2026-06-17 01:44:15 -05:00

57 lines
1.2 KiB
TypeScript

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;