fix(datamart): added some fixed some
This commit is contained in:
52
server/services/dataMart/route/getOpenOrders.ts
Normal file
52
server/services/dataMart/route/getOpenOrders.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
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";
|
||||
|
||||
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: "/getopenorders",
|
||||
// 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
|
||||
);
|
||||
}
|
||||
|
||||
return c.json({
|
||||
success: data.success,
|
||||
message: data.message,
|
||||
data: data.data,
|
||||
});
|
||||
}
|
||||
);
|
||||
export default app;
|
||||
Reference in New Issue
Block a user