feat(notificaitons): fixed and corrections to get them working properly
This commit is contained in:
@@ -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;
|
||||
|
||||
50
server/services/notifications/routes/qualityBlocking.ts
Normal file
50
server/services/notifications/routes/qualityBlocking.ts
Normal 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;
|
||||
Reference in New Issue
Block a user