48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
|
|
import { apiHit } from "../../../globalUtils/apiHits.js";
|
|
import { responses } from "../../../globalUtils/routeDefs/responses.js";
|
|
import { getActiveAv } from "../controller/getActiveArticles.js";
|
|
|
|
const app = new OpenAPIHono({ strict: false });
|
|
const EomStat = z.object({
|
|
plant: z.string().openapi({ example: "Salt Lake City" }),
|
|
userRan: z.string().openapi({ example: "smith034" }),
|
|
eomSheetVersion: z.string().openapi({ example: "0.0.223" }),
|
|
});
|
|
|
|
app.openapi(
|
|
createRoute({
|
|
tags: ["dataMart"],
|
|
summary: "Returns all the Active articles.",
|
|
method: "get",
|
|
path: "/getarticles",
|
|
|
|
responses: responses(),
|
|
}),
|
|
async (c) => {
|
|
//const body = await c.req.json();
|
|
// make sure we have a vaid user being accessed thats really logged in
|
|
apiHit(c, { endpoint: "/getarticles" });
|
|
try {
|
|
return c.json(
|
|
{
|
|
success: true,
|
|
message: "Current active Articles",
|
|
data: await getActiveAv(),
|
|
},
|
|
200
|
|
);
|
|
} catch (error) {
|
|
return c.json(
|
|
{
|
|
success: false,
|
|
message: "There was an error posting the eom stat.",
|
|
data: error,
|
|
},
|
|
400
|
|
);
|
|
}
|
|
}
|
|
);
|
|
export default app;
|