remove casts

This commit is contained in:
Alex Holliday committed 2026-03-20 10:37:29 -07:00
1 parent 210881a375
commit f69752ccb4
3 files changed
+18 -18

No files matched your search

@@ -59,7 +59,6 @@ class MonitorController {
const monitorId = validatedParams.monitorId; const monitorId = validatedParams.monitorId;
const dateRange = validatedQuery.dateRange; const dateRange = validatedQuery.dateRange;
const normalize = validatedQuery.normalize;
const teamId = requireTeamId(req.user?.teamId); const teamId = requireTeamId(req.user?.teamId);
@@ -67,7 +66,6 @@ class MonitorController {
teamId, teamId,
monitorId, monitorId,
dateRange, dateRange,
normalize,
}); });
return res.status(200).json({ return res.status(200).json({
success: true, success: true,
@@ -323,7 +321,6 @@ class MonitorController {
try { try {
const validatedQuery = getMonitorsWithChecksQueryValidation.parse(req.query); const validatedQuery = getMonitorsWithChecksQueryValidation.parse(req.query);
const explain = validatedQuery.explain;
const limit = validatedQuery.limit; const limit = validatedQuery.limit;
const page = validatedQuery.page; const page = validatedQuery.page;
const rowsPerPage = validatedQuery.rowsPerPage; const rowsPerPage = validatedQuery.rowsPerPage;
@@ -342,7 +339,6 @@ class MonitorController {
filter, filter,
field, field,
order, order,
explain,
}); });
return res.status(200).json({ return res.status(200).json({
+16 -14
View File
@@ -21,6 +21,7 @@ import type {
} from "@/repositories/index.js"; } from "@/repositories/index.js";
import demoMonitorsData from "@/utils/demoMonitors.json" with { type: "json" }; import demoMonitorsData from "@/utils/demoMonitors.json" with { type: "json" };
import { AppError } from "@/utils/AppError.js"; import { AppError } from "@/utils/AppError.js";
import type { ImportedMonitor } from "@/validation/monitorValidation.js";
import { ISuperSimpleQueue } from "../infrastructure/SuperSimpleQueue/SuperSimpleQueue.js"; import { ISuperSimpleQueue } from "../infrastructure/SuperSimpleQueue/SuperSimpleQueue.js";
import { IEmailService } from "../infrastructure/emailService.js"; import { IEmailService } from "../infrastructure/emailService.js";
import { ILogger } from "@/utils/logger.js"; import { ILogger } from "@/utils/logger.js";
@@ -37,7 +38,7 @@ export interface IMonitorService {
addDemoMonitors(args: { userId: string; teamId: string }): Promise<Monitor[]>; addDemoMonitors(args: { userId: string; teamId: string }): Promise<Monitor[]>;
// read // read
getUptimeDetailsById(args: { teamId: string; monitorId: string; dateRange: string; normalize?: boolean }): Promise<UptimeDetailsResult>; getUptimeDetailsById(args: { teamId: string; monitorId: string; dateRange: string }): Promise<UptimeDetailsResult>;
getHardwareDetailsById(args: { teamId: string; monitorId: string; dateRange: string }): Promise<HardwareDetailsResult>; getHardwareDetailsById(args: { teamId: string; monitorId: string; dateRange: string }): Promise<HardwareDetailsResult>;
getPageSpeedDetailsById(args: { teamId: string; monitorId: string; dateRange: string }): Promise<PageSpeedDetailsResult>; getPageSpeedDetailsById(args: { teamId: string; monitorId: string; dateRange: string }): Promise<PageSpeedDetailsResult>;
getGeoChecksByMonitorId(args: { getGeoChecksByMonitorId(args: {
@@ -66,7 +67,6 @@ export interface IMonitorService {
filter?: string; filter?: string;
field?: string; field?: string;
order?: "asc" | "desc"; order?: "asc" | "desc";
explain?: boolean;
}): Promise<MonitorsWithChecksByTeamIdResult>; }): Promise<MonitorsWithChecksByTeamIdResult>;
getAllGames(): GamesMap; getAllGames(): GamesMap;
getGroupsByTeamId(args: { teamId: string }): Promise<string[]>; getGroupsByTeamId(args: { teamId: string }): Promise<string[]>;
@@ -81,7 +81,7 @@ export interface IMonitorService {
// other // other
exportMonitorsToJSON(args: { teamId: string }): Promise<Monitor[]>; exportMonitorsToJSON(args: { teamId: string }): Promise<Monitor[]>;
importMonitorsFromJSON(args: { teamId: string; userId: string; monitors: Partial<Monitor>[] }): Promise<{ imported: number; errors: string[] }>; importMonitorsFromJSON(args: { teamId: string; userId: string; monitors: ImportedMonitor[] }): Promise<{ imported: number; errors: string[] }>;
} }
export class MonitorService implements IMonitorService { export class MonitorService implements IMonitorService {
@@ -528,24 +528,26 @@ export class MonitorService implements IMonitorService {
importMonitorsFromJSON = async ({ importMonitorsFromJSON = async ({
teamId, teamId,
userId,
monitors, monitors,
}: { }: {
teamId: string; teamId: string;
monitors: Partial<Monitor>[]; userId: string;
monitors: ImportedMonitor[];
}): Promise<{ imported: number; errors: string[] }> => { }): Promise<{ imported: number; errors: string[] }> => {
const errors: string[] = []; const errors: string[] = [];
const cleanedMonitors = monitors.map((monitor) => { const cleanedMonitors: Monitor[] = monitors.map((monitor) => ({
const cleanData = { ...monitor }; ...monitor,
delete cleanData.id; id: "",
delete cleanData.createdAt; teamId,
delete cleanData.updatedAt; userId,
delete cleanData.recentChecks; recentChecks: [],
cleanData.teamId = teamId; createdAt: "",
return cleanData; updatedAt: "",
}); }));
const createdMonitors = await this.createMonitors(cleanedMonitors as Monitor[]); const createdMonitors = await this.createMonitors(cleanedMonitors);
if (!createdMonitors || createdMonitors.length === 0) { if (!createdMonitors || createdMonitors.length === 0) {
throw new AppError({ throw new AppError({
@@ -168,6 +168,8 @@ export const importMonitorsBodyValidation = z.object({
monitors: z.array(importedMonitorSchema).min(1, "At least one monitor is required"), monitors: z.array(importedMonitorSchema).min(1, "At least one monitor is required"),
}); });
export type ImportedMonitor = z.output<typeof importedMonitorSchema>;
export const getHardwareDetailsByIdParamValidation = z.object({ export const getHardwareDetailsByIdParamValidation = z.object({
monitorId: z.string().min(1, "Monitor ID is required"), monitorId: z.string().min(1, "Monitor ID is required"),
}); });