export team incidents

This commit is contained in:
Alex Holliday committed 2025-12-08 23:18:46 +00:00
1 parent 36208aacea
commit e12e198aed
4 files changed
+88 -9

No files matched your search

@@ -12,6 +12,7 @@ export interface IIncidentsController {
getIncidents: (req: Request, res: Response, next: NextFunction) => void;
getIncidentById: (req: Request, res: Response, next: NextFunction) => void;
resolveIncident: (req: Request, res: Response, next: NextFunction) => void;
exportIncidents: (req: Request, res: Response, next: NextFunction) => void;
}
class IncidentsController implements IIncidentsController {
@@ -136,6 +137,26 @@ class IncidentsController implements IIncidentsController {
next(error);
}
};
exportIncidents = async (req: Request, res: Response, next: NextFunction) => {
try {
const userContext = req.user;
if (!userContext) {
return res.status(401).json({ message: "Unauthorized" });
}
const teamId = userContext.currentTeamId;
if (!teamId) {
throw new ApiError("No team ID", 400);
}
const incidents = await this.incidentService.export(teamId);
return res.status(200).json({ message: "OK", data: incidents });
} catch (error) {
next(error);
}
};
}
export default IncidentsController;