feat(datamart): initial get active query migrated

This commit is contained in:
2025-04-01 16:20:18 -05:00
parent ee3026fa7c
commit 44507d41c4
12 changed files with 565 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
import { query } from "../../sqlServer/prodSqlServer.js";
import { activeArticle } from "../../sqlServer/querys/dataMart/article.js";
export const getActiveAv = async () => {
let articles: any = [];
try {
articles = await query(activeArticle, "Get active articles");
} catch (error) {
articles = error;
}
return articles;
};

View File

@@ -0,0 +1,13 @@
import { OpenAPIHono } from "@hono/zod-openapi";
import getArticles from "./route/getActiveArticles.js";
const app = new OpenAPIHono();
const routes = [getArticles] as const;
const appRoutes = routes.forEach((route) => {
app.route("/datamart", route);
});
export default app;

View File

@@ -0,0 +1,47 @@
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: `api/logger/logs/id` });
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;