Skip to content

Commit ed77fc3

Browse files
committed
js->ts
1 parent 8ceac49 commit ed77fc3

File tree

3 files changed

+89
-194
lines changed

3 files changed

+89
-194
lines changed

server/src/config/controllers.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ export const initializeControllers = (services) => {
4646
diagnosticService: services.diagnosticService,
4747
});
4848

49-
controllers.incidentController = new IncidentController(commonDependencies, {
50-
incidentService: services.incidentService,
51-
});
49+
controllers.incidentController = new IncidentController(services.incidentService);
5250

5351
return controllers;
5452
};

server/src/controllers/v1/incidentController.js

Lines changed: 0 additions & 191 deletions
This file was deleted.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { Request, Response, NextFunction } from "express";
2+
3+
const SERVICE_NAME = "incidentController";
4+
5+
class IncidentController {
6+
static SERVICE_NAME = SERVICE_NAME;
7+
8+
private incidentService: any;
9+
constructor(incidentService: any) {
10+
this.incidentService = incidentService;
11+
}
12+
13+
get serviceName() {
14+
return IncidentController.SERVICE_NAME;
15+
}
16+
17+
getIncidentsByTeam = async (req: Request, res: Response, next: NextFunction) => {
18+
try {
19+
const result = await this.incidentService.getIncidentsByTeam({
20+
teamId: req?.user?.teamId,
21+
query: req?.query,
22+
});
23+
24+
return res.status(200).json({
25+
success: true,
26+
msg: "Incidents retrieved successfully",
27+
data: result,
28+
});
29+
} catch (error) {
30+
next(error);
31+
}
32+
};
33+
34+
getIncidentSummary = async (req: Request, res: Response, next: NextFunction) => {
35+
try {
36+
const summary = await this.incidentService.getIncidentSummary({
37+
teamId: req?.user?.teamId,
38+
query: req?.query,
39+
});
40+
41+
return res.status(200).json({
42+
success: true,
43+
msg: "Incident summary retrieved successfully",
44+
data: summary,
45+
});
46+
} catch (error) {
47+
next(error);
48+
}
49+
};
50+
51+
getIncidentById = async (req: Request, res: Response, next: NextFunction) => {
52+
try {
53+
const incident = await this.incidentService.getIncidentById({
54+
incidentId: req?.params?.incidentId,
55+
teamId: req?.user?.teamId,
56+
});
57+
58+
return res.status(200).json({
59+
success: true,
60+
msg: "Incident retrieved successfully",
61+
data: incident,
62+
});
63+
} catch (error) {
64+
next(error);
65+
}
66+
};
67+
68+
resolveIncidentManually = async (req: Request, res: Response, next: NextFunction) => {
69+
try {
70+
const resolvedIncident = await this.incidentService.resolveIncidentManually({
71+
incidentId: req?.params?.incidentId,
72+
userId: req?.user?._id,
73+
teamId: req?.user?.teamId,
74+
comment: req?.body?.comment,
75+
});
76+
77+
return res.status(200).json({
78+
success: true,
79+
msg: "Incident resolved successfully",
80+
data: resolvedIncident,
81+
});
82+
} catch (error) {
83+
next(error);
84+
}
85+
};
86+
}
87+
88+
export default IncidentController;

0 commit comments

Comments
 (0)