fix(datamart): added some fixed some
This commit is contained in:
69
server/services/dataMart/route/getSiloAdjustments.ts
Normal file
69
server/services/dataMart/route/getSiloAdjustments.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import { getOpenOrders } from "../controller/getOpenOrders.js";
|
||||
import axios from "axios";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
// const Body = z.object({
|
||||
// includeRunnningNumbers: z.string().openapi({ example: "x" }),
|
||||
// });
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["dataMart"],
|
||||
summary: "Returns All open orders.",
|
||||
method: "get",
|
||||
path: "/getsilosdjustment",
|
||||
// request: {
|
||||
// body: {
|
||||
// content: {
|
||||
// "application/json": { schema: Body },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
const customer: any = c.req.queries();
|
||||
|
||||
// make sure we have a vaid user being accessed thats really logged in
|
||||
//apiHit(c, { endpoint: `api/logger/logs/id` });
|
||||
// const { data, error } = await tryCatch(
|
||||
// getOpenOrders(customer ? customer : null)
|
||||
// );
|
||||
|
||||
// if (error) {
|
||||
// return c.json(
|
||||
// {
|
||||
// success: false,
|
||||
// message: "There was an error getting the inv.",
|
||||
// data: error,
|
||||
// },
|
||||
// 400
|
||||
// );
|
||||
// }
|
||||
|
||||
const dates: any = c.req.queries();
|
||||
|
||||
const { data, error } = await tryCatch(
|
||||
axios.get(
|
||||
`http://localhost:4400/api/v1/warehouse/getSilosAdjustment?startDate=${dates.startDate[0]}&endDate=${dates.endDate[0]}`
|
||||
)
|
||||
);
|
||||
|
||||
if (error) {
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "Error running query",
|
||||
data: error,
|
||||
});
|
||||
}
|
||||
|
||||
return c.json({
|
||||
success: data?.data.success,
|
||||
message: data?.data.message,
|
||||
data: data?.data.data,
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
Reference in New Issue
Block a user