feat(datamart): psi data has been added :D
This commit is contained in:
@@ -3,6 +3,7 @@ import { eq } from "drizzle-orm";
|
||||
import { db } from "../db/db.controller.js";
|
||||
import { jobAuditLog } from "../db/schema/auditLog.schema.js";
|
||||
import { createLogger } from "../logger/logger.controller.js";
|
||||
import type { ReturnHelper } from "./returnHelper.utils.js";
|
||||
|
||||
// example createJob
|
||||
// createCronJob("test Cron", "*/5 * * * * *", async () => {
|
||||
@@ -45,7 +46,7 @@ const cronStats: Record<string, { created: number; replaced: number }> = {};
|
||||
export const createCronJob = async (
|
||||
name: string,
|
||||
schedule: string, // cron string with 8 8 IE: */5 * * * * * every 5th second
|
||||
task: () => Promise<void>, // what function are we passing over
|
||||
task: () => Promise<void | ReturnHelper>, // what function are we passing over
|
||||
source = "unknown",
|
||||
) => {
|
||||
// get the timezone based on the os timezone set
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Response } from "express";
|
||||
import { createLogger } from "../logger/logger.controller.js";
|
||||
|
||||
interface Data<T = unknown[]> {
|
||||
export interface ReturnHelper<T = unknown[]> {
|
||||
success: boolean;
|
||||
module:
|
||||
| "system"
|
||||
@@ -13,31 +13,10 @@ interface Data<T = unknown[]> {
|
||||
| "notification"
|
||||
| "email"
|
||||
| "purchase"
|
||||
| "tcp";
|
||||
subModule:
|
||||
| "db"
|
||||
| "labeling"
|
||||
| "printer"
|
||||
| "prodSql"
|
||||
| "query"
|
||||
| "sendmail"
|
||||
| "auth"
|
||||
| "datamart"
|
||||
| "jobs"
|
||||
| "apt"
|
||||
| "settings"
|
||||
| "get"
|
||||
| "update"
|
||||
| "delete"
|
||||
| "post"
|
||||
| "notification"
|
||||
| "delete"
|
||||
| "printing"
|
||||
| "gpSql"
|
||||
| "email"
|
||||
| "gpChecks"
|
||||
| "prodEndpoint"
|
||||
| "create_server";
|
||||
| "tcp"
|
||||
| "logistics";
|
||||
subModule: string;
|
||||
|
||||
level: "info" | "error" | "debug" | "fatal" | "warn";
|
||||
message: string;
|
||||
room?: string;
|
||||
@@ -59,7 +38,7 @@ interface Data<T = unknown[]> {
|
||||
* data: [] the data that will be passed back
|
||||
* notify: false by default this is to send a notification to a users email to alert them of an issue.
|
||||
*/
|
||||
export const returnFunc = (data: Data) => {
|
||||
export const returnFunc = (data: ReturnHelper) => {
|
||||
const notify = data.notify ? data.notify : false;
|
||||
const room = data.room ?? data.room;
|
||||
const log = createLogger({ module: data.module, subModule: data.subModule });
|
||||
@@ -92,7 +71,7 @@ export const returnFunc = (data: Data) => {
|
||||
|
||||
export function apiReturn(
|
||||
res: Response,
|
||||
opts: Data & { status?: number },
|
||||
opts: ReturnHelper & { status?: number },
|
||||
optional?: unknown, // leave this as unknown so we can pass an object or an array over.
|
||||
): Response {
|
||||
const result = returnFunc(opts);
|
||||
|
||||
Reference in New Issue
Block a user