test(silo): backend silo stuff
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { responses } from "../../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { getOpenOrders } from "../../../dataMart/controller/getOpenOrders.js";
|
||||
import axios from "axios";
|
||||
import { getSiloAdjustments } from "../../controller/siloAdjustments/getSiloAdjustments.js";
|
||||
|
||||
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: any) => {
|
||||
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(
|
||||
// `/api/v1/warehouse/getSilosAdjustment?startDate=${dates.startDate[0]}&endDate=${dates.endDate[0]}`
|
||||
// )
|
||||
// );
|
||||
const startDate = dates.startDate ? dates.startDate[0] : null;
|
||||
const endDate = dates.endDate ? dates.endDate[0] : null;
|
||||
|
||||
const { data, error } = await tryCatch(
|
||||
getSiloAdjustments(startDate, endDate)
|
||||
);
|
||||
|
||||
if (error) {
|
||||
console.log(error);
|
||||
return c.json({
|
||||
success: false,
|
||||
message: "Error running query",
|
||||
data: error,
|
||||
});
|
||||
}
|
||||
|
||||
return c.json({
|
||||
success: data?.success,
|
||||
message: data?.message,
|
||||
data: data?.data,
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
@@ -59,6 +59,8 @@ app.openapi(
|
||||
data.key,
|
||||
payload.user
|
||||
);
|
||||
|
||||
console.log(addComment);
|
||||
return c.json(
|
||||
{
|
||||
success: addComment.success,
|
||||
|
||||
Reference in New Issue
Block a user