feat(datamart): total inv migrated over
This commit is contained in:
54
server/services/dataMart/route/getInventory.ts
Normal file
54
server/services/dataMart/route/getInventory.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
||||
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
import { getINV } from "../controller/getinventory.js";
|
||||
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
|
||||
app.openapi(
|
||||
createRoute({
|
||||
tags: ["dataMart"],
|
||||
summary: "Returns All current inventory.",
|
||||
method: "get",
|
||||
path: "/getinventory",
|
||||
// request: {
|
||||
// body: {
|
||||
// content: {
|
||||
// "application/json": { schema: Body },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
responses: responses(),
|
||||
}),
|
||||
async (c) => {
|
||||
// const { data: body, error } = await c.req.json();
|
||||
|
||||
// if (error) {
|
||||
// return c.json({
|
||||
// success: false,
|
||||
// message: "Missing data please try again.",
|
||||
// });
|
||||
// }
|
||||
// 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(getINV());
|
||||
|
||||
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