feat(notificaitons): fixed and corrections to get them working properly

This commit is contained in:
2025-04-04 17:12:48 -05:00
parent 99477bac19
commit a7818b4ca3
21 changed files with 888 additions and 633 deletions

View File

@@ -1,22 +1,26 @@
// import {Router} from "express";
// import {tiExportRunning, runTiImport} from "../../notification/notification/tiFullFlow/tiImports.js";
// an external way to creating logs
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { responses } from "../../../globalUtils/routeDefs/responses.js";
// const router = Router();
import runTiImport from "../controller/notifications/tiIntergration.js";
// router.get("/tiTrigger", async (req, res): Promise<void> => {
// if (tiExportRunning) {
// res.status(200).json({
// success: false,
// message: "There is already a current sesion of the Export running please try again later.",
// });
// }
const app = new OpenAPIHono({ strict: false });
// // trigger the import
// runTiImport();
// res.status(200).json({
// success: true,
// message: "The Ti Export has been manually started and will continue to run in the background.",
// });
// });
// export default router;
app.openapi(
createRoute({
tags: ["notify"],
summary: "Manually trigger TI intergrations.",
method: "get",
path: "/tiTrigger",
//middleware: authMiddleware,
responses: responses(),
}),
async (c) => {
const tiImport = await runTiImport();
return c.json({
success: tiImport?.success,
message: tiImport?.message,
});
}
);
export default app;

View File

@@ -0,0 +1,50 @@
// an external way to creating logs
import { createRoute, OpenAPIHono, z } from "@hono/zod-openapi";
import { responses } from "../../../globalUtils/routeDefs/responses.js";
import qualityBlockingMonitor from "../controller/notifications/qualityBlocking.js";
import { tryCatch } from "../../../globalUtils/tryCatch.js";
import { notifications } from "../../../../database/schema/notifications.js";
import { db } from "../../../../database/dbclient.js";
import { eq } from "drizzle-orm";
const app = new OpenAPIHono({ strict: false });
app.openapi(
createRoute({
tags: ["notify"],
summary: "Manually trigger TI intergrations.",
method: "get",
path: "/blockingTrigger",
//middleware: authMiddleware,
responses: responses(),
}),
async (c) => {
/**
* get the blocking notification stuff
*/
const { data, error } = await tryCatch(
db
.select()
.from(notifications)
.where(eq(notifications.name, "qualityBlocking"))
);
if (error) {
return c.json({
success: false,
message: "Error Getting Notification Settings.",
data: error,
});
}
const blocking = await qualityBlockingMonitor(data[0]);
return c.json({
success: blocking?.success,
message: blocking?.message,
});
}
);
export default app;