first commit

This commit is contained in:
2026-01-02 15:49:01 +03:00
commit 4348f76a7c
80 changed files with 10133 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
import { Server } from "socket.io";
import { EVENTS } from "./events";
import { StatusSnapshot } from "../status/status.service";
import { LoopJob, TimerLog, TimerSummary } from "../types";
let io: Server | null = null;
export const initEmitter = (server: Server) => {
io = server;
};
export const emitStatusSnapshot = (snapshot: StatusSnapshot) => {
io?.emit(EVENTS.STATUS_SNAPSHOT, snapshot);
};
export const emitStatusUpdate = (snapshot: StatusSnapshot) => {
io?.emit(EVENTS.STATUS_UPDATE, snapshot);
};
export const emitJobMetrics = (job: LoopJob) => {
io?.emit(EVENTS.JOB_METRICS, job);
};
export const emitJobLog = (payload: {
jobId: string;
level: "INFO" | "WARN" | "ERROR";
message: string;
createdAt: string;
}) => {
io?.emit(EVENTS.JOB_LOG, payload);
};
export const emitQbitHealth = (payload: StatusSnapshot["qbit"]) => {
io?.emit(EVENTS.QBIT_HEALTH, payload);
};
export const emitTimerLog = (payload: TimerLog) => {
io?.emit(EVENTS.TIMER_LOG, payload);
};
export const emitTimerSummary = (payload: TimerSummary) => {
io?.emit(EVENTS.TIMER_SUMMARY, payload);
};