purge incident module

This commit is contained in:
Alex Holliday committed 2026-01-22 21:28:28 +00:00
1 parent 5292ca8988
commit d25ca473de
8 files changed
+63 -544

No files matched your search

@@ -4,6 +4,7 @@ export interface IIncidentsRepository {
// create
create(incident: Partial<Incident>): Promise<Incident>;
// fetch
findById(incidentId: string, teamId: string): Promise<Incident>;
findActiveByIncidentId(incidentId: string, teamId: string): Promise<Incident | null>;
findActiveByMonitorId(monitorId: string, teamId: string): Promise<Incident | null>;
findByTeamId(
@@ -79,6 +79,17 @@ class MongoIncidentRepository implements IIncidentsRepository {
return this.toEntity(newIncident);
}
findById = async (incidentId: string, teamId: string): Promise<Incident> => {
const incident = await IncidentModel.findOne({
_id: new mongoose.Types.ObjectId(incidentId),
teamId: new mongoose.Types.ObjectId(teamId),
});
if (!incident) {
throw new AppError({ message: `Incident with id ${incidentId} not found`, status: 404 });
}
return this.toEntity(incident);
};
findActiveByIncidentId = async (incidentId: string, teamId: string): Promise<Incident | null> => {
const incident = await IncidentModel.findOne({
_id: new mongoose.Types.ObjectId(incidentId),