refactor: Clean up import statements and improve code formatting in API files

This commit is contained in:
Nawaz Dhandala
2025-12-16 16:02:24 +00:00
parent 4966468d99
commit 1526b59ff5
3 changed files with 25 additions and 28 deletions

View File

@@ -82,9 +82,7 @@ import DashboardService, {
import AlertOwnerUserService, {
Service as AlertOwnerUserServiceType,
} from "Common/Server/Services/AlertOwnerUserService";
import AlertService, {
Service as AlertServiceType,
} from "Common/Server/Services/AlertService";
import AlertSeverityService, {
Service as AlertSeverityServiceType,
} from "Common/Server/Services/AlertSeverityService";
@@ -236,9 +234,7 @@ import ScheduledMaintenanceOwnerTeamService, {
import ScheduledMaintenanceOwnerUserService, {
Service as ScheduledMaintenanceOwnerUserServiceType,
} from "Common/Server/Services/ScheduledMaintenanceOwnerUserService";
import ScheduledMaintenanceService, {
Service as ScheduledMaintenanceServiceType,
} from "Common/Server/Services/ScheduledMaintenanceService";
import ScheduledMaintenanceStateService, {
Service as ScheduledMaintenanceStateServiceType,
} from "Common/Server/Services/ScheduledMaintenanceStateService";
@@ -388,7 +384,6 @@ import EmailLog from "Common/Models/DatabaseModels/EmailLog";
import EmailVerificationToken from "Common/Models/DatabaseModels/EmailVerificationToken";
import Dashboard from "Common/Models/DatabaseModels/Dashboard";
import Alert from "Common/Models/DatabaseModels/Alert";
import AlertCustomField from "Common/Models/DatabaseModels/AlertCustomField";
import AlertNoteTemplate from "Common/Models/DatabaseModels/AlertNoteTemplate";
import AlertOwnerTeam from "Common/Models/DatabaseModels/AlertOwnerTeam";
@@ -435,7 +430,6 @@ import ProjectSmtpConfig from "Common/Models/DatabaseModels/ProjectSmtpConfig";
import PromoCode from "Common/Models/DatabaseModels/PromoCode";
import CodeRepository from "Common/Models/DatabaseModels/CodeRepository";
import Reseller from "Common/Models/DatabaseModels/Reseller";
import ScheduledMaintenance from "Common/Models/DatabaseModels/ScheduledMaintenance";
import ScheduledMaintenanceCustomField from "Common/Models/DatabaseModels/ScheduledMaintenanceCustomField";
import ScheduledMaintenanceNoteTemplate from "Common/Models/DatabaseModels/ScheduledMaintenanceNoteTemplate";
import ScheduledMaintenanceOwnerTeam from "Common/Models/DatabaseModels/ScheduledMaintenanceOwnerTeam";
@@ -828,10 +822,7 @@ const BaseAPIFeatureSet: FeatureSet = {
).getRouter(),
);
app.use(
`/${APP_NAME.toLocaleLowerCase()}`,
new AlertAPI().getRouter(),
);
app.use(`/${APP_NAME.toLocaleLowerCase()}`, new AlertAPI().getRouter());
app.use(
`/${APP_NAME.toLocaleLowerCase()}`,

View File

@@ -296,10 +296,9 @@ export default class IncidentAPI extends BaseAPI<
"template",
) as string | undefined;
const noteType: string = (JSONFunctions.getJSONValueInPath(
req.body,
"noteType",
) as string) || "internal";
const noteType: string =
(JSONFunctions.getJSONValueInPath(req.body, "noteType") as string) ||
"internal";
if (noteType !== "public" && noteType !== "internal") {
throw new BadDataException("Note type must be 'public' or 'internal'");
@@ -341,7 +340,10 @@ export default class IncidentAPI extends BaseAPI<
// Generate note using AIService (handles billing and logging)
const aiLogRequest: AILogRequest = {
projectId: incident.projectId,
feature: noteType === "public" ? "Incident Public Note" : "Incident Internal Note",
feature:
noteType === "public"
? "Incident Public Note"
: "Incident Internal Note",
incidentId: incidentId,
messages: aiContext.messages,
maxTokens: 4096,

View File

@@ -18,22 +18,26 @@ export default class Domain extends DatabaseProperty {
}
public static isValidDomain(domain: string): boolean {
// Regex-based domain validation
// - Each label (part between dots) must be 1-63 characters
// - Labels can contain alphanumeric characters and hyphens
// - Labels cannot start or end with a hyphen
// - TLD must be at least 2 characters and contain only letters
// - Total length should not exceed 253 characters
/*
* Regex-based domain validation
* - Each label (part between dots) must be 1-63 characters
* - Labels can contain alphanumeric characters and hyphens
* - Labels cannot start or end with a hyphen
* - TLD must be at least 2 characters and contain only letters
* - Total length should not exceed 253 characters
*/
if (!domain || domain.length > 253) {
return false;
}
// Domain validation regex:
// ^ - start of string
// (?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+ - one or more labels followed by dot
// [a-zA-Z]{2,63} - TLD: 2-63 letters only
// $ - end of string
/*
* Domain validation regex:
* ^ - start of string
* (?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+ - one or more labels followed by dot
* [a-zA-Z]{2,63} - TLD: 2-63 letters only
* $ - end of string
*/
const domainRegex: RegExp =
/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/;