Merge pull request #3366 from bluewave-labs/fix/eslint-warnings
fix: eslint warnings
This commit is contained in:
11 files changed
+59
-42
No files matched your search
@@ -7,7 +7,7 @@ const __filename = fileURLToPath(import.meta.url);
|
|||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
export default defineConfig(({}) => {
|
export default defineConfig(({}) => {
|
||||||
let version = "3.4.0";
|
let version = "3.5.0";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
base: "/",
|
base: "/",
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import { MonitorModel } from "../dist/db/models/Monitor.js";
|
|||||||
import { CheckModel } from "../dist/db/models/Check.js";
|
import { CheckModel } from "../dist/db/models/Check.js";
|
||||||
|
|
||||||
const DEFAULT_MONITOR_ID = "000000000000000000000001";
|
const DEFAULT_MONITOR_ID = "000000000000000000000001";
|
||||||
const DEFAULT_TEAM_ID = "0000000000000000000000aa";
|
|
||||||
const DEFAULT_USER_ID = "0000000000000000000000bb";
|
|
||||||
const DEFAULT_MONITOR_TYPE = "http";
|
const DEFAULT_MONITOR_TYPE = "http";
|
||||||
const DEFAULT_TOTAL = 1_000_000;
|
const DEFAULT_TOTAL = 1_000_000;
|
||||||
const DEFAULT_BATCH_SIZE = 5_000;
|
const DEFAULT_BATCH_SIZE = 5_000;
|
||||||
@@ -12,7 +10,7 @@ const DEFAULT_BATCH_SIZE = 5_000;
|
|||||||
const parseObjectId = (value, fallback) => {
|
const parseObjectId = (value, fallback) => {
|
||||||
try {
|
try {
|
||||||
return new mongoose.Types.ObjectId(value || fallback);
|
return new mongoose.Types.ObjectId(value || fallback);
|
||||||
} catch (error) {
|
} catch {
|
||||||
console.warn(`Invalid ObjectId '${value}', falling back to '${fallback}'.`);
|
console.warn(`Invalid ObjectId '${value}', falling back to '${fallback}'.`);
|
||||||
return new mongoose.Types.ObjectId(fallback);
|
return new mongoose.Types.ObjectId(fallback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import { NotificationMessageBuilder, INotificationMessageBuilder } from "../serv
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import got from "got";
|
import got from "got";
|
||||||
import ping from "ping";
|
import ping from "ping";
|
||||||
import http from "http";
|
|
||||||
import https from "https";
|
import https from "https";
|
||||||
import Docker from "dockerode";
|
import Docker from "dockerode";
|
||||||
import net from "net";
|
import net from "net";
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import { requireTeamId, requireUserId } from "@/controllers/controllerUtils.js";
|
|||||||
import { IStatusPageService } from "@/service/business/statusPageService.js";
|
import { IStatusPageService } from "@/service/business/statusPageService.js";
|
||||||
import { IMonitorsRepository } from "@/repositories/index.js";
|
import { IMonitorsRepository } from "@/repositories/index.js";
|
||||||
import { ISettingsService } from "@/service/system/settingsService.js";
|
import { ISettingsService } from "@/service/system/settingsService.js";
|
||||||
import { ParseBoolean } from "@/utils/utils.js";
|
|
||||||
import { NormalizeData } from "@/utils/dataUtils.js";
|
import { NormalizeData } from "@/utils/dataUtils.js";
|
||||||
|
|
||||||
const SERVICE_NAME = "statusPageController";
|
const SERVICE_NAME = "statusPageController";
|
||||||
@@ -110,6 +109,7 @@ class StatusPageController {
|
|||||||
const normalizedMonitors = sortedMonitors.map((monitor) => {
|
const normalizedMonitors = sortedMonitors.map((monitor) => {
|
||||||
const normalizedChecks = NormalizeData(monitor.recentChecks, 10, 100);
|
const normalizedChecks = NormalizeData(monitor.recentChecks, 10, 100);
|
||||||
if (!showURL) {
|
if (!showURL) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const { url, port, secret, notifications, ...rest } = monitor;
|
const { url, port, secret, notifications, ...rest } = monitor;
|
||||||
return { ...rest, checks: normalizedChecks };
|
return { ...rest, checks: normalizedChecks };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class MongoInvitesRepository implements IInvitesRepository {
|
|||||||
create = async (invite: Partial<Invite>) => {
|
create = async (invite: Partial<Invite>) => {
|
||||||
await InviteModel.deleteMany({ email: invite.email });
|
await InviteModel.deleteMany({ email: invite.email });
|
||||||
invite.token = crypto.randomBytes(32).toString("hex");
|
invite.token = crypto.randomBytes(32).toString("hex");
|
||||||
let inviteToken = await InviteModel.create(invite);
|
const inviteToken = await InviteModel.create(invite);
|
||||||
return this.toEntity(inviteToken);
|
return this.toEntity(inviteToken);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class MongoMaintenanceWindowsRepository implements IMaintenanceWindowsRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sorting
|
// Sorting
|
||||||
let sort: Record<string, any> = {};
|
const sort: Record<string, any> = {};
|
||||||
if (field !== undefined && order !== undefined) {
|
if (field !== undefined && order !== undefined) {
|
||||||
sort[field] = order === "asc" ? 1 : -1;
|
sort[field] = order === "asc" ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class MongoSettingsRepository implements ISettingsRepository {
|
|||||||
};
|
};
|
||||||
|
|
||||||
findSingleton = async () => {
|
findSingleton = async () => {
|
||||||
let settings = await AppSettingsModel.findOne({ singleton: true }).select("-__v -_id -createdAt -updatedAt -singleton").lean();
|
const settings = await AppSettingsModel.findOne({ singleton: true }).select("-__v -_id -createdAt -updatedAt -singleton").lean();
|
||||||
if (!settings) {
|
if (!settings) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ class GeoChecksService implements IGeoChecksService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let { sortOrder, dateRange, page, rowsPerPage, continent } = query;
|
const { sortOrder, dateRange, page, rowsPerPage, continent } = query;
|
||||||
const continents = continent ? (Array.isArray(continent) ? continent : [continent]) : undefined;
|
const continents = continent ? (Array.isArray(continent) ? continent : [continent]) : undefined;
|
||||||
|
|
||||||
this.logger.debug({
|
this.logger.debug({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const SERVICE_NAME = "JobQueueHelper";
|
|||||||
import type { Monitor } from "@/types/monitor.js";
|
import type { Monitor } from "@/types/monitor.js";
|
||||||
import { AppError } from "@/utils/AppError.js";
|
import { AppError } from "@/utils/AppError.js";
|
||||||
import { INetworkService, INotificationsService, IStatusService } from "@/service/index.js";
|
import { INetworkService, INotificationsService, IStatusService } from "@/service/index.js";
|
||||||
import type { StatusChangeResult, MonitorStatusResponse, HardwareStatusPayload, MonitorStatus } from "@/types/index.js";
|
import type { StatusChangeResult } from "@/types/index.js";
|
||||||
import IncidentService from "@/service/business/incidentService.js";
|
import IncidentService from "@/service/business/incidentService.js";
|
||||||
import type { IGeoChecksService } from "@/service/business/geoChecksService.js";
|
import type { IGeoChecksService } from "@/service/business/geoChecksService.js";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,11 +1,21 @@
|
|||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from "url";
|
||||||
import path from "path";
|
|
||||||
import { EmailTransportConfig } from "@/types/index.js";
|
import { EmailTransportConfig } from "@/types/index.js";
|
||||||
|
import { ISettingsService } from "@/service/system/settingsService.js";
|
||||||
|
import { ILogger } from "@/utils/logger.js";
|
||||||
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import nodemailer from "nodemailer";
|
||||||
|
import mjml2html from "mjml";
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
const SERVICE_NAME = "EmailService";
|
const SERVICE_NAME = "EmailService";
|
||||||
|
type MjmlFn = typeof mjml2html;
|
||||||
|
type FileSystem = typeof fs;
|
||||||
|
type PathModule = typeof path;
|
||||||
|
type Mailer = typeof nodemailer;
|
||||||
|
type TemplateCompiler = (template: string) => (context: Record<string, unknown>) => string;
|
||||||
|
|
||||||
export interface IEmailService {
|
export interface IEmailService {
|
||||||
init(): void;
|
init(): void;
|
||||||
@@ -16,18 +26,26 @@ export interface IEmailService {
|
|||||||
class EmailService implements IEmailService {
|
class EmailService implements IEmailService {
|
||||||
static SERVICE_NAME = SERVICE_NAME;
|
static SERVICE_NAME = SERVICE_NAME;
|
||||||
|
|
||||||
private settingsService: any;
|
private settingsService: ISettingsService;
|
||||||
private fs: any;
|
private fs: FileSystem;
|
||||||
private path: any;
|
private path: PathModule;
|
||||||
private compile: any;
|
private compile: TemplateCompiler;
|
||||||
private mjml2html: any;
|
private mjml2html: MjmlFn;
|
||||||
private nodemailer: any;
|
private nodemailer: Mailer;
|
||||||
private logger: any;
|
private logger: ILogger;
|
||||||
private transporter: any;
|
private transporter: ReturnType<typeof import("nodemailer").createTransport> | null = null;
|
||||||
private templateLookup: Record<string, Function>;
|
private templateLookup: Record<string, ((context: Record<string, unknown>) => string) | undefined>;
|
||||||
private loadTemplate: (templateName: string) => Function;
|
private loadTemplate: (templateName: string) => ((context: Record<string, unknown>) => string) | undefined;
|
||||||
|
|
||||||
constructor(settingsService: any, fs: any, path: any, compile: any, mjml2html: any, nodemailer: any, logger: any) {
|
constructor(
|
||||||
|
settingsService: ISettingsService,
|
||||||
|
fs: FileSystem,
|
||||||
|
path: PathModule,
|
||||||
|
compile: TemplateCompiler,
|
||||||
|
mjml2html: MjmlFn,
|
||||||
|
nodemailer: Mailer,
|
||||||
|
logger: ILogger
|
||||||
|
) {
|
||||||
this.settingsService = settingsService;
|
this.settingsService = settingsService;
|
||||||
this.fs = fs;
|
this.fs = fs;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
@@ -36,9 +54,7 @@ class EmailService implements IEmailService {
|
|||||||
this.nodemailer = nodemailer;
|
this.nodemailer = nodemailer;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.templateLookup = {};
|
this.templateLookup = {};
|
||||||
this.loadTemplate = () => {
|
this.loadTemplate = () => undefined;
|
||||||
return () => {};
|
|
||||||
};
|
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,12 +68,12 @@ class EmailService implements IEmailService {
|
|||||||
const templatePath = this.path.join(__dirname, `../../templates/${templateName}.mjml`);
|
const templatePath = this.path.join(__dirname, `../../templates/${templateName}.mjml`);
|
||||||
const templateContent = this.fs.readFileSync(templatePath, "utf8");
|
const templateContent = this.fs.readFileSync(templatePath, "utf8");
|
||||||
return this.compile(templateContent);
|
return this.compile(templateContent);
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
this.logger.error({
|
this.logger.error({
|
||||||
message: error.message,
|
message: error instanceof Error ? error.message : "Unknown error",
|
||||||
service: SERVICE_NAME,
|
service: SERVICE_NAME,
|
||||||
method: "loadTemplate",
|
method: "loadTemplate",
|
||||||
stack: error.stack,
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -72,17 +88,20 @@ class EmailService implements IEmailService {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
buildEmail = async (template: string, context: Record<string, any>) => {
|
buildEmail = async (template: string, context: Record<string, unknown>) => {
|
||||||
try {
|
try {
|
||||||
const mjml = this.templateLookup[template]?.(context);
|
const mjml = this.templateLookup[template]?.(context);
|
||||||
const html = await this.mjml2html(mjml);
|
if (!mjml) {
|
||||||
|
throw new Error(`Template ${template} not found`);
|
||||||
|
}
|
||||||
|
const html = this.mjml2html(mjml);
|
||||||
return html.html;
|
return html.html;
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
this.logger.error({
|
this.logger.error({
|
||||||
message: error.message,
|
message: error instanceof Error ? error.message : "Unknown error",
|
||||||
service: SERVICE_NAME,
|
service: SERVICE_NAME,
|
||||||
method: "buildEmail",
|
method: "buildEmail",
|
||||||
stack: error.stack,
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -131,11 +150,12 @@ class EmailService implements IEmailService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await this.transporter.verify();
|
await this.transporter.verify();
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
this.logger.warn({
|
this.logger.warn({
|
||||||
message: "Email transporter verification failed",
|
message: "Email transporter verification failed",
|
||||||
service: SERVICE_NAME,
|
service: SERVICE_NAME,
|
||||||
method: "verifyTransporter",
|
method: "verifyTransporter",
|
||||||
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -148,12 +168,12 @@ class EmailService implements IEmailService {
|
|||||||
html: html,
|
html: html,
|
||||||
});
|
});
|
||||||
return info?.messageId;
|
return info?.messageId;
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
this.logger.error({
|
this.logger.error({
|
||||||
message: error.message,
|
message: error instanceof Error ? error.message : "Unknown error",
|
||||||
service: SERVICE_NAME,
|
service: SERVICE_NAME,
|
||||||
method: "sendEmail",
|
method: "sendEmail",
|
||||||
stack: error.stack,
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -95,12 +95,12 @@ class GlobalPingService implements IGlobalPingService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return measurementId;
|
return measurementId;
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
this.logger.error({
|
this.logger.error({
|
||||||
message: "GlobalPing API unavailable, skipping geo check",
|
message: "GlobalPing API unavailable, skipping geo check",
|
||||||
service: SERVICE_NAME,
|
service: SERVICE_NAME,
|
||||||
method: "createMeasurement",
|
method: "createMeasurement",
|
||||||
details: error,
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -140,12 +140,12 @@ class GlobalPingService implements IGlobalPingService {
|
|||||||
|
|
||||||
// Still in-progress, wait and poll again
|
// Still in-progress, wait and poll again
|
||||||
await this.sleep(POLL_INTERVAL_MS);
|
await this.sleep(POLL_INTERVAL_MS);
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
this.logger.error({
|
this.logger.error({
|
||||||
message: "Error polling GlobalPing API",
|
message: "Error polling GlobalPing API",
|
||||||
service: SERVICE_NAME,
|
service: SERVICE_NAME,
|
||||||
method: "pollForResults",
|
method: "pollForResults",
|
||||||
details: error.message,
|
stack: error instanceof Error ? error.stack : undefined,
|
||||||
});
|
});
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user