44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
|
|
|
import { lastPurchase } from "../controller/getLastPurchasesPrice.js";
|
|
import { lastSales } from "../controller/getLastestSalesPrice.js";
|
|
|
|
const app = new OpenAPIHono({ strict: false });
|
|
|
|
app.openapi(
|
|
createRoute({
|
|
tags: ["eom"],
|
|
summary: "Returns last sales price.",
|
|
method: "get",
|
|
path: "/lastsalesprice",
|
|
responses: responses(),
|
|
}),
|
|
async (c) => {
|
|
//const body = await c.req.json();
|
|
const month: string = c.req.query("month") ?? "";
|
|
// make sure we have a vaid user being accessed thats really logged in
|
|
|
|
apiHit(c, { endpoint: "/lastsalesprice" });
|
|
try {
|
|
const res = await lastSales(month);
|
|
|
|
return c.json(
|
|
{ success: res.success, message: res.message, data: res.data },
|
|
200
|
|
);
|
|
} catch (error) {
|
|
return c.json(
|
|
{
|
|
success: false,
|
|
message: "There was an error posting the eom stat.",
|
|
data: error,
|
|
},
|
|
400
|
|
);
|
|
}
|
|
}
|
|
);
|
|
export default app;
|