update routes, validation

This commit is contained in:
Alex Holliday committed 2025-06-13 10:46:06 +08:00
1 parent d9c2f31f4e
commit afece4df65
8 files changed
+17 -23

No files matched your search

+4 -3
View File
@@ -519,7 +519,8 @@ const getMonitorsByTeamId = async (req) => {
order = "asc";
}
// Build match stage
const matchStage = { teamId: ObjectId.createFromHexString(req.params.teamId) };
const teamId = req.user.teamId;
const matchStage = { teamId: ObjectId.createFromHexString(teamId) };
if (type !== undefined) {
matchStage.type = Array.isArray(type) ? { $in: type } : type;
}
@@ -560,7 +561,7 @@ const getMonitorsByTeamId = async (req) => {
const getMonitorsAndSummaryByTeamId = async (req) => {
try {
const { type } = req.query;
const teamId = ObjectId.createFromHexString(req.params.teamId);
const teamId = ObjectId.createFromHexString(req.user.teamId);
const matchStage = { teamId };
if (type !== undefined) {
matchStage.type = Array.isArray(type) ? { $in: type } : type;
@@ -594,7 +595,7 @@ const getMonitorsWithChecksByTeamId = async (req) => {
field = "name";
order = "asc";
}
const teamId = ObjectId.createFromHexString(req.params.teamId);
const teamId = ObjectId.createFromHexString(req.user.teamId);
// Build match stage
const matchStage = { teamId };
if (type !== undefined) {
+4 -4
View File
@@ -35,17 +35,17 @@ class MonitorRoutes {
fetchMonitorCertificate
);
});
this.router.get("/team", this.monitorController.getMonitorsByTeamId);
this.router.get("/:monitorId", this.monitorController.getMonitorById);
this.router.get("/team/:teamId", this.monitorController.getMonitorsByTeamId);
this.router.get(
"/summary/team/:teamId",
"/summary/team",
this.monitorController.getMonitorsAndSummaryByTeamId
);
this.router.get(
"/team/:teamId/with-checks",
"/team/with-checks",
this.monitorController.getMonitorsWithChecksByTeamId
);
+1 -3
View File
@@ -126,9 +126,7 @@ const getMonitorByIdQueryValidation = joi.object({
normalize: joi.boolean(),
});
const getMonitorsByTeamIdParamValidation = joi.object({
teamId: joi.string().required(),
});
const getMonitorsByTeamIdParamValidation = joi.object({});
const getMonitorsByTeamIdQueryValidation = joi.object({
limit: joi.number(),