This commit is contained in:
Alex Holliday committed 2025-12-13 16:58:30 +00:00
1 parent 92f7a929fa
commit 16c7a007d5
4 files changed
+48 -1

No files matched your search

@@ -162,6 +162,7 @@ export const InfraMonitorsTable = ({
id: "name", id: "name",
content: ( content: (
<Typography <Typography
component="div"
display="inline-flex" display="inline-flex"
alignItems="center" alignItems="center"
gap={theme.spacing(4)} gap={theme.spacing(4)}
@@ -180,6 +181,7 @@ export const InfraMonitorsTable = ({
id: "status", id: "status",
content: ( content: (
<Typography <Typography
component="div"
display="inline-flex" display="inline-flex"
alignItems="center" alignItems="center"
gap={theme.spacing(4)} gap={theme.spacing(4)}
+10 -1
View File
@@ -1,10 +1,10 @@
import { Request, Response, NextFunction } from "express"; import { Request, Response, NextFunction } from "express";
import type { IDiagnosticService } from "@/services/business/DiagnosticService.js"; import type { IDiagnosticService } from "@/services/business/DiagnosticService.js";
import type { IJobData } from "@/services/infrastructure/JobQueue.js";
export interface IDiagnosticController { export interface IDiagnosticController {
getLogs: (req: Request, res: Response, next: NextFunction) => void; getLogs: (req: Request, res: Response, next: NextFunction) => void;
getJobs(req: Request, res: Response, next: NextFunction): Promise<void>; getJobs(req: Request, res: Response, next: NextFunction): Promise<void>;
getEnv(req: Request, res: Response, next: NextFunction): void;
} }
class DiagnosticController implements IDiagnosticController { class DiagnosticController implements IDiagnosticController {
@@ -30,6 +30,15 @@ class DiagnosticController implements IDiagnosticController {
next(error); next(error);
} }
}; };
getEnv = (req: Request, res: Response, next: NextFunction) => {
try {
const data = this.diagnosticService.getEnv();
res.status(200).json({ message: "OK", data });
} catch (error) {
next(error);
}
};
} }
export default DiagnosticController; export default DiagnosticController;
+8
View File
@@ -29,6 +29,14 @@ class DiagnosticRoutes {
verifyOrgPermission([PERMISSIONS.master]), verifyOrgPermission([PERMISSIONS.master]),
this.controller.getJobs this.controller.getJobs
); );
this.router.get(
"/env",
verifyToken,
addUserContext,
verifyOrgPermission([PERMISSIONS.master]),
this.controller.getEnv
);
}; };
getRouter() { getRouter() {
@@ -4,6 +4,7 @@ import type {
IJobMetrics, IJobMetrics,
} from "@/services/infrastructure/JobQueue.js"; } from "@/services/infrastructure/JobQueue.js";
import { memoryTransport } from "@/logger/Logger.js"; import { memoryTransport } from "@/logger/Logger.js";
import { config, type IEnvConfig } from "@/config/index.js";
export interface IDiagnosticService { export interface IDiagnosticService {
getLogs: () => any[]; getLogs: () => any[];
@@ -11,6 +12,7 @@ export interface IDiagnosticService {
jobs: IJobData[] | null; jobs: IJobData[] | null;
metrics: IJobMetrics | null; metrics: IJobMetrics | null;
}>; }>;
getEnv: () => IEnvConfig;
} }
const SERVICE_NAME = "DiagnosticService"; const SERVICE_NAME = "DiagnosticService";
@@ -32,6 +34,32 @@ class DiagnosticService implements IDiagnosticService {
const metrics = await this.jobQueue.getMetrics(); const metrics = await this.jobQueue.getMetrics();
return { jobs, metrics }; return { jobs, metrics };
}; };
getEnv = (): IEnvConfig => {
const mask = (val: string | undefined | null): string => {
const isDev = (config.NODE_ENV || "").toLowerCase() === "development";
if (isDev) return val ?? "";
if (val === undefined || val === null) return "";
if (val.length <= 4) return "***";
return `${val.slice(0, 2)}***${val.slice(-2)}`;
};
return {
NODE_ENV: config.NODE_ENV,
DEPLOYMENT_MODE: config.DEPLOYMENT_MODE,
LOG_LEVEL: config.LOG_LEVEL,
ORIGIN: config.ORIGIN,
JWT_SECRET: mask(config.JWT_SECRET),
PORT: config.PORT,
PAGESPEED_API_KEY: mask(config.PAGESPEED_API_KEY),
SMTP_HOST: config.SMTP_HOST,
SMTP_PORT: config.SMTP_PORT,
SMTP_USER: mask(config.SMTP_USER),
SMTP_PASS: mask(config.SMTP_PASS),
STRIPE_SECRET: mask(config.STRIPE_SECRET),
STRIPE_WEBHOOK_SECRET: mask(config.STRIPE_WEBHOOK_SECRET),
};
};
} }
export default DiagnosticService; export default DiagnosticService;