parse query

This commit is contained in:
Alex Holliday committed 2026-01-21 10:15:13 -08:00
1 parent 3fa370765e
commit ef61a63da0
2 files changed
+24 -7

No files matched your search

+14 -5
View File
@@ -1,5 +1,6 @@
import { AppError } from "@/utils/AppError.js";
import { Request, Response, NextFunction } from "express";
import { requireTeamId } from "./controllerUtils.js";
const SERVICE_NAME = "incidentController";
@@ -17,10 +18,19 @@ class IncidentController {
getIncidentsByTeam = async (req: Request, res: Response, next: NextFunction) => {
try {
const result = await this.incidentService.getIncidentsByTeam({
teamId: req?.user?.teamId,
query: req?.query,
});
const { sortOrder, dateRange, page, rowsPerPage, status, monitorId, resolutionType } = req.query || {};
const teamId = requireTeamId(req.user?.teamId);
const result = await this.incidentService.getIncidentsByTeam(
teamId,
sortOrder,
dateRange,
page,
rowsPerPage,
status,
monitorId,
resolutionType
);
return res.status(200).json({
success: true,
@@ -73,7 +83,6 @@ class IncidentController {
resolveIncidentManually = async (req: Request, res: Response, next: NextFunction) => {
try {
console.log({ user: req.user });
const resolvedIncident = await this.incidentService.resolveIncident(
req?.params?.incidentId,
req?.user?.id,
+10 -2
View File
@@ -124,13 +124,21 @@ class IncidentService {
}
};
getIncidentsByTeam = async ({ teamId, query }: { teamId: string; query?: any }) => {
getIncidentsByTeam = async (
teamId: string,
sortOrder: string,
dateRange: string,
page: string,
rowsPerPage: string,
status: string,
monitorId: string,
resolutionType: string
) => {
try {
if (!teamId) {
throw this.errorService.createBadRequestError("No team ID in request");
}
const { sortOrder, dateRange, page, rowsPerPage, status, monitorId, resolutionType } = query || {};
const startDate = dateRangeLookup[dateRange];
const parsedPage = Number.isFinite(parseInt(page)) ? parseInt(page) : 0;