mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
compile common-server
This commit is contained in:
@@ -500,14 +500,15 @@ router.get(
|
||||
const newElement = {
|
||||
_id: elem._id,
|
||||
name: elem.name,
|
||||
type: `${elem.type === 'server-monitor'
|
||||
? 'server monitor'
|
||||
: elem.type === 'url'
|
||||
type: `${
|
||||
elem.type === 'server-monitor'
|
||||
? 'server monitor'
|
||||
: elem.type === 'url'
|
||||
? 'website monitor'
|
||||
: elem.type === 'ip'
|
||||
? 'IP monitor'
|
||||
: elem.type + ` monitor`
|
||||
}`,
|
||||
? 'IP monitor'
|
||||
: elem.type + ` monitor`
|
||||
}`,
|
||||
createdAt: elem.createdAt,
|
||||
icon: 'monitor',
|
||||
slug: elem.slug,
|
||||
|
||||
@@ -1136,8 +1136,9 @@ router.post(
|
||||
error
|
||||
);
|
||||
});
|
||||
const status = `${incidentMessage.type} notes ${data.id ? 'updated' : 'added'
|
||||
}`;
|
||||
const status = `${incidentMessage.type} notes ${
|
||||
data.id ? 'updated' : 'added'
|
||||
}`;
|
||||
|
||||
const user = await UserService.findOneBy({
|
||||
query: { _id: userId },
|
||||
|
||||
@@ -704,34 +704,34 @@ router.post(
|
||||
successReasons: upSuccessReasons,
|
||||
failedReasons: upFailedReasons,
|
||||
} = monitor && monitor.criteria && monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
const {
|
||||
stat: validDegraded,
|
||||
successReasons: degradedSuccessReasons,
|
||||
failedReasons: degradedFailedReasons,
|
||||
} = monitor && monitor.criteria && monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
const {
|
||||
stat: validDown,
|
||||
successReasons: downSuccessReasons,
|
||||
failedReasons: downFailedReasons,
|
||||
} = monitor && monitor.criteria && monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.down,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.down,
|
||||
data
|
||||
)
|
||||
: { stat: false, failedReasons: [], successReasons: [] };
|
||||
|
||||
if (validUp) {
|
||||
data.status = 'online';
|
||||
|
||||
@@ -199,65 +199,65 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDegraded,
|
||||
successReasons: degradedSuccessReasons,
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDown,
|
||||
successReasons: downSuccessReasons,
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
if (validUp) {
|
||||
status = 'online';
|
||||
@@ -304,45 +304,45 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDown,
|
||||
successReasons: downSuccessReasons,
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
res,
|
||||
resp,
|
||||
rawResp
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
if (validUp) {
|
||||
status = 'online';
|
||||
reason = upSuccessReasons;
|
||||
@@ -381,17 +381,17 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.up
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.up
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDown,
|
||||
@@ -399,19 +399,19 @@ router.post(
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.scriptConditions(resp, [
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
])
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.scriptConditions(resp, [
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
])
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDegraded,
|
||||
@@ -419,17 +419,17 @@ router.post(
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.degraded
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.scriptConditions(
|
||||
resp,
|
||||
monitor.criteria.degraded
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
if (validUp) {
|
||||
status = 'online';
|
||||
@@ -474,59 +474,59 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDegraded,
|
||||
successReasons: degradedSuccessReasons,
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
const {
|
||||
stat: validDown,
|
||||
successReasons: downSuccessReasons,
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
data
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
if (validUp) {
|
||||
data.status = 'online';
|
||||
@@ -618,19 +618,19 @@ router.post(
|
||||
failedReasons: upFailedReasons,
|
||||
matchedCriterion: matchedUpCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
monitor.criteria &&
|
||||
monitor.criteria.up
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.up,
|
||||
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDegraded,
|
||||
@@ -638,19 +638,19 @@ router.post(
|
||||
failedReasons: degradedFailedReasons,
|
||||
matchedCriterion: matchedDegradedCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
monitor.criteria &&
|
||||
monitor.criteria.degraded
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
monitor.criteria.degraded,
|
||||
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
const {
|
||||
stat: validDown,
|
||||
@@ -658,24 +658,24 @@ router.post(
|
||||
failedReasons: downFailedReasons,
|
||||
matchedCriterion: matchedDownCriterion,
|
||||
}: $TSFixMe = monitor &&
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
monitor.criteria &&
|
||||
monitor.criteria.down
|
||||
? ProbeService.conditions(
|
||||
monitor.type,
|
||||
[
|
||||
...monitor.criteria.down.filter(
|
||||
(criterion: $TSFixMe) =>
|
||||
criterion.default !== true
|
||||
),
|
||||
],
|
||||
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
data.kubernetesData
|
||||
)
|
||||
: {
|
||||
stat: false,
|
||||
successReasons: [],
|
||||
failedReasons: [],
|
||||
};
|
||||
|
||||
if (validUp) {
|
||||
data.status = 'online';
|
||||
@@ -740,9 +740,9 @@ router.post(
|
||||
data.reason =
|
||||
data && data.reason && data.reason.length
|
||||
? data.reason.filter(
|
||||
(item: $TSFixMe, pos: $TSFixMe, self: $TSFixMe) =>
|
||||
self.indexOf(item) === pos
|
||||
)
|
||||
(item: $TSFixMe, pos: $TSFixMe, self: $TSFixMe) =>
|
||||
self.indexOf(item) === pos
|
||||
)
|
||||
: data.reason;
|
||||
const index =
|
||||
data.reason && data.reason.indexOf('Request Timed out');
|
||||
@@ -750,9 +750,9 @@ router.post(
|
||||
data.reason =
|
||||
data && data.reason && data.reason.length
|
||||
? data.reason.filter(
|
||||
(item: $TSFixMe) =>
|
||||
!item.includes('Response Time is')
|
||||
)
|
||||
(item: $TSFixMe) =>
|
||||
!item.includes('Response Time is')
|
||||
)
|
||||
: data.reason;
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ router.post(
|
||||
'Please select how should OneUptime alert your team - SMS, Email, Call OR Push notification ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -280,7 +280,7 @@ router.post(
|
||||
'Number of Email Reminders is required ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -292,7 +292,7 @@ router.post(
|
||||
'Number of Call Reminders is required ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -304,7 +304,7 @@ router.post(
|
||||
'Number of SMS Reminders is required ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -316,7 +316,7 @@ router.post(
|
||||
'Number of Push notification Reminders is required ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -328,7 +328,7 @@ router.post(
|
||||
'Please specify Rotation Interval ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -344,7 +344,7 @@ router.post(
|
||||
'Please specify "First rotation happens on" ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -361,7 +361,7 @@ router.post(
|
||||
'You must specify timezone for "First rotation happens on" ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -373,7 +373,7 @@ router.post(
|
||||
'You need more than one team for rotations ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -455,7 +455,7 @@ router.post(
|
||||
'Team Members are required ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -473,7 +473,7 @@ router.post(
|
||||
'Please add team members or group to your on-call schedule ' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
@@ -491,7 +491,7 @@ router.post(
|
||||
'Please remove duplicate team members from your on-call schedule' +
|
||||
(req.body.length > 1
|
||||
? ' in Escalation Policy ' +
|
||||
escalationPolicyCount
|
||||
escalationPolicyCount
|
||||
: ''),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1056,14 +1056,17 @@ router.get(
|
||||
|
||||
guid: `${global.apiHost}/status-page/${statusPageId}/rss/${incident._id}`,
|
||||
pubDate: new Date(incident.createdAt).toUTCString(),
|
||||
description: `<![CDATA[Description: ${incident.description
|
||||
}<br>Incident Id: ${incident._id.toString()} <br>Monitor Name(s): ${handleMonitorList(
|
||||
incident.monitors
|
||||
)}<br>Acknowledge Time: ${incident.acknowledgedAt
|
||||
}<br>Resolve Time: ${incident.resolvedAt}<br>${incident.investigationNote
|
||||
description: `<![CDATA[Description: ${
|
||||
incident.description
|
||||
}<br>Incident Id: ${incident._id.toString()} <br>Monitor Name(s): ${handleMonitorList(
|
||||
incident.monitors
|
||||
)}<br>Acknowledge Time: ${
|
||||
incident.acknowledgedAt
|
||||
}<br>Resolve Time: ${incident.resolvedAt}<br>${
|
||||
incident.investigationNote
|
||||
? `Investigation Note: ${incident.investigationNote}`
|
||||
: ''
|
||||
}]]>`,
|
||||
}]]>`,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -2343,8 +2346,9 @@ function handleMonitorList(monitors: $TSFixMe) {
|
||||
return `${monitors[0].monitorId.name}, ${monitors[1].monitorId.name} and ${monitors[2].monitorId.name}`;
|
||||
}
|
||||
if (monitors.length > 3) {
|
||||
return `${monitors[0].monitorId.name}, ${monitors[1].monitorId.name
|
||||
} and ${monitors.length - 2} others`;
|
||||
return `${monitors[0].monitorId.name}, ${
|
||||
monitors[1].monitorId.name
|
||||
} and ${monitors.length - 2} others`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2992,18 +2996,18 @@ const filterProbeData = (
|
||||
monitorStatuses && monitorStatuses.length > 0
|
||||
? probe
|
||||
? monitorStatuses.filter((probeStatuses: $TSFixMe) => {
|
||||
return (
|
||||
probeStatuses._id === null ||
|
||||
String(probeStatuses._id) === String(probe._id)
|
||||
);
|
||||
})
|
||||
return (
|
||||
probeStatuses._id === null ||
|
||||
String(probeStatuses._id) === String(probe._id)
|
||||
);
|
||||
})
|
||||
: monitorStatuses
|
||||
: [];
|
||||
const statuses =
|
||||
probesStatus &&
|
||||
probesStatus[0] &&
|
||||
probesStatus[0].statuses &&
|
||||
probesStatus[0].statuses.length > 0
|
||||
probesStatus[0] &&
|
||||
probesStatus[0].statuses &&
|
||||
probesStatus[0].statuses.length > 0
|
||||
? probesStatus[0].statuses
|
||||
: [];
|
||||
|
||||
|
||||
@@ -522,14 +522,14 @@ router.post('/sso/callback', async function (req: Request, res: Response) {
|
||||
|
||||
return res.redirect(
|
||||
`${global.accountsHost}` +
|
||||
`/ssologin?id=${authUserObj.id}` +
|
||||
`&name=${authUserObj.name}` +
|
||||
`&email=${authUserObj.email}` +
|
||||
`&jwtAccessToken=${authUserObj.tokens.jwtAccessToken}` +
|
||||
`&jwtRefreshToken=${authUserObj.tokens.jwtRefreshToken}` +
|
||||
`&role=${authUserObj.role}` +
|
||||
`&redirect=${authUserObj.redirect}` +
|
||||
`&cardRegistered=${authUserObj.cardRegistered}`
|
||||
`/ssologin?id=${authUserObj.id}` +
|
||||
`&name=${authUserObj.name}` +
|
||||
`&email=${authUserObj.email}` +
|
||||
`&jwtAccessToken=${authUserObj.tokens.jwtAccessToken}` +
|
||||
`&jwtRefreshToken=${authUserObj.tokens.jwtRefreshToken}` +
|
||||
`&role=${authUserObj.role}` +
|
||||
`&redirect=${authUserObj.redirect}` +
|
||||
`&cardRegistered=${authUserObj.cardRegistered}`
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -1312,7 +1312,7 @@ router.get(
|
||||
if (!token) {
|
||||
return res.redirect(
|
||||
global.accountsHost +
|
||||
'/user-verify/resend?status=link-expired'
|
||||
'/user-verify/resend?status=link-expired'
|
||||
);
|
||||
}
|
||||
const user = await UserModel.findOne({
|
||||
@@ -1351,7 +1351,7 @@ router.get(
|
||||
} else {
|
||||
return res.redirect(
|
||||
global.accountsHost +
|
||||
'/user-verify/resend?status=invalid-verification-link'
|
||||
'/user-verify/resend?status=invalid-verification-link'
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -89,11 +89,13 @@ app.use(async function (req: Request, res: Response, next: NextFunction) {
|
||||
req.logdata = logdata;
|
||||
|
||||
logger.info(
|
||||
`INCOMING REQUEST ID: ${req.id} -- POD NAME: ${process.env['POD_NAME']
|
||||
`INCOMING REQUEST ID: ${req.id} -- POD NAME: ${
|
||||
process.env['POD_NAME']
|
||||
} -- RECEIVED AT: ${new Date()} -- METHOD: ${method} -- URL: ${url}`
|
||||
);
|
||||
logger.info(
|
||||
`INCOMING REQUEST ID: ${req.id} -- REQUEST BODY: ${req.body ? JSON.stringify(req.body, null, 2) : 'EMPTY'
|
||||
`INCOMING REQUEST ID: ${req.id} -- REQUEST BODY: ${
|
||||
req.body ? JSON.stringify(req.body, null, 2) : 'EMPTY'
|
||||
}`
|
||||
);
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ describe('Incident Custom Field API', function () {
|
||||
customFieldId: $TSFixMe;
|
||||
|
||||
const incidentFieldText = {
|
||||
fieldName: 'inTextField',
|
||||
fieldType: 'text',
|
||||
},
|
||||
fieldName: 'inTextField',
|
||||
fieldType: 'text',
|
||||
},
|
||||
incidentFieldNumber = {
|
||||
fieldName: 'inNumField',
|
||||
fieldType: 'number',
|
||||
|
||||
@@ -1128,8 +1128,9 @@ describe('SMS/Calls Incident Alerts', function () {
|
||||
|
||||
const randomId = uuid.v4();
|
||||
|
||||
const link = `http://localhost:${process.env['PORT'] || 3002
|
||||
}/api/incomingHttpRequest/${randomId}`;
|
||||
const link = `http://localhost:${
|
||||
process.env['PORT'] || 3002
|
||||
}/api/incomingHttpRequest/${randomId}`;
|
||||
|
||||
// create a new incomingHttp monitor, with a resource that will fail
|
||||
const newMonitor = await createMonitor({
|
||||
@@ -1916,7 +1917,7 @@ describe('SMS/Calls Incident Alerts', function () {
|
||||
(subscriberAlert: $TSFixMe) =>
|
||||
subscriberAlert.alertVia === 'sms' &&
|
||||
subscriberAlert.errorMessage ===
|
||||
'Investigation Note SMS Notification Disabled'
|
||||
'Investigation Note SMS Notification Disabled'
|
||||
);
|
||||
expect(statusPageNoteNotificationAlert).to.be.an('object');
|
||||
});
|
||||
@@ -3104,7 +3105,7 @@ describe('Email Incident Alerts', function () {
|
||||
(subscriberAlert: $TSFixMe) =>
|
||||
subscriberAlert.alertVia === 'email' &&
|
||||
subscriberAlert.errorMessage ===
|
||||
'Investigation Note Email Notification Disabled'
|
||||
'Investigation Note Email Notification Disabled'
|
||||
);
|
||||
expect(statusPageNoteNotificationAlert).to.be.an('object');
|
||||
});
|
||||
@@ -3506,7 +3507,7 @@ describe('Webhook Incident Alerts', function () {
|
||||
(subscriberAlert: $TSFixMe) =>
|
||||
subscriberAlert.alertVia === 'webhook' &&
|
||||
subscriberAlert.errorMessage ===
|
||||
'Investigation Note Webhook Notification Disabled'
|
||||
'Investigation Note Webhook Notification Disabled'
|
||||
);
|
||||
expect(statusPageNoteNotificationAlert).to.be.an('object');
|
||||
});
|
||||
|
||||
@@ -28,9 +28,9 @@ describe('Monitor Custom Field API', function () {
|
||||
monitorCustomFieldId: $TSFixMe;
|
||||
|
||||
const monitorFieldText = {
|
||||
fieldName: 'textField',
|
||||
fieldType: 'text',
|
||||
},
|
||||
fieldName: 'textField',
|
||||
fieldType: 'text',
|
||||
},
|
||||
monitorFieldNumber = {
|
||||
fieldName: 'numField',
|
||||
fieldType: 'number',
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
export type JSONValue =
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| { [x: string]: JSONValue }
|
||||
| Array<JSONValue>;
|
||||
export type JSONValue = string | number | boolean | JSONObject | JSONArray;
|
||||
|
||||
export interface JSONObject {
|
||||
[x: string]: JSONValue;
|
||||
}
|
||||
|
||||
export interface JSONArray extends Array<JSONObject> { }
|
||||
export interface JSONArray extends Array<JSONObject> {}
|
||||
|
||||
export class JSONFunctions {
|
||||
toCompressedString(val: JSONValue): string {
|
||||
return JSON.stringify(val, null, 2);
|
||||
}
|
||||
|
||||
toString(val: JSONValue): string {
|
||||
return JSON.stringify(val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import { JSONArray, JSONValue } from './json';
|
||||
|
||||
export class ListData {
|
||||
constructor(data: JSONArray, count: number, skip: number, limit: number) {
|
||||
this.data = data;
|
||||
this.count = count;
|
||||
this.skip = skip;
|
||||
this.limit = limit;
|
||||
constructor(obj: {
|
||||
data: JSONArray;
|
||||
count: number;
|
||||
skip: number;
|
||||
limit: number;
|
||||
}) {
|
||||
this.data = obj.data;
|
||||
this.count = obj.count;
|
||||
this.skip = obj.skip;
|
||||
this.limit = obj.limit;
|
||||
}
|
||||
|
||||
public data: JSONArray;
|
||||
@@ -19,7 +24,7 @@ export class ListData {
|
||||
count: this.count,
|
||||
skip: this.skip,
|
||||
limit: this.limit,
|
||||
}
|
||||
};
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -2,23 +2,22 @@ import MongoDB from 'mongodb';
|
||||
import { databaseUrl, databaseName } from '../config';
|
||||
|
||||
export default class Database {
|
||||
static databaseClient: MongoDB.MongoClient;
|
||||
static databaseConnected: boolean = false;
|
||||
private static databaseClient: MongoDB.MongoClient;
|
||||
private static databaseConnected: boolean = false;
|
||||
|
||||
static getClient(): MongoDB.MongoClient {
|
||||
public static getClient(): MongoDB.MongoClient {
|
||||
this.databaseClient = new MongoDB.MongoClient(databaseUrl);
|
||||
|
||||
return this.databaseClient;
|
||||
}
|
||||
|
||||
static async connect() {
|
||||
public static async connect() {
|
||||
if (!this.databaseClient) {
|
||||
await this.getClient();
|
||||
}
|
||||
await this.databaseClient.connect();
|
||||
}
|
||||
|
||||
static async getDatabase(): Promise<MongoDB.Db> {
|
||||
public static async getDatabase(): Promise<MongoDB.Db> {
|
||||
if (!this.databaseConnected) {
|
||||
await this.connect();
|
||||
this.databaseConnected = true;
|
||||
|
||||
@@ -33,9 +33,9 @@ class Express {
|
||||
this.app.set('port', process.env['PORT']);
|
||||
|
||||
const logRequest = (
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
req: express.Request,
|
||||
res: express.Response,
|
||||
next: express.NextFunction
|
||||
) => {
|
||||
const current_datetime = new Date();
|
||||
const formatted_date =
|
||||
@@ -50,6 +50,7 @@ class Express {
|
||||
current_datetime.getMinutes() +
|
||||
':' +
|
||||
current_datetime.getSeconds();
|
||||
|
||||
const method = req.method;
|
||||
const url = req.url;
|
||||
const status = res.statusCode;
|
||||
@@ -60,9 +61,9 @@ class Express {
|
||||
};
|
||||
|
||||
const setDefaultHeaders = (
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
req: express.Request,
|
||||
res: express.Response,
|
||||
next: express.NextFunction
|
||||
) => {
|
||||
if (typeof req.body === 'string') {
|
||||
req.body = JSON.parse(req.body);
|
||||
|
||||
@@ -9,7 +9,7 @@ export default {
|
||||
'Cannot convert to CSV when the object length is 0'
|
||||
);
|
||||
}
|
||||
const fields = Object.keys(json[0]);
|
||||
const fields = Object.keys(json[0] || {});
|
||||
const opts = { fields };
|
||||
const parser = new Json2Csv.Parser(opts);
|
||||
return parser.parse(json);
|
||||
|
||||
@@ -6,18 +6,22 @@ import { JSONObject, JSONArray, JSONValue } from '../types/json';
|
||||
import { File } from '../types/file';
|
||||
import { Exception } from '../types/error';
|
||||
import { ListData } from '../types/list';
|
||||
import Database from './database';
|
||||
|
||||
function logResponse(req: Request, res: Response, responsebody: JSONValue) {
|
||||
const requestEndedAt = Date();
|
||||
function logResponse(req: Request, res: Response, responsebody?: JSONValue) {
|
||||
const requestEndedAt: Date = new Date();
|
||||
const method = req.method;
|
||||
const url = req.url;
|
||||
|
||||
const duration_info = `OUTGOING RESPONSE ID: ${req.id} -- POD NAME: ${process.env['POD_NAME']
|
||||
} -- METHOD: ${method} -- URL: ${url} -- DURATION: ${requestEndedAt.getTime() - req.requestStartedAt.getTime()
|
||||
}ms -- STATUS: ${res.statusCode}`;
|
||||
const duration_info = `OUTGOING RESPONSE ID: ${req.id} -- POD NAME: ${
|
||||
process.env['POD_NAME'] || 'NONE'
|
||||
} -- METHOD: ${method} -- URL: ${url} -- DURATION: ${(
|
||||
requestEndedAt.getTime() - req.requestStartedAt.getTime()
|
||||
).toString()}ms -- STATUS: ${res.statusCode}`;
|
||||
|
||||
const body_info = `OUTGOING RESPONSE ID: ${req.id} -- RESPONSE BODY: ${responsebody ? JSON.stringify(responsebody, null, 2) : 'EMPTY'
|
||||
}`;
|
||||
const body_info = `OUTGOING RESPONSE ID: ${req.id} -- RESPONSE BODY: ${
|
||||
responsebody ? JSON.stringify(responsebody, null, 2) : 'EMPTY'
|
||||
}`;
|
||||
|
||||
if (res.statusCode > 299) {
|
||||
logger.error(duration_info);
|
||||
@@ -34,13 +38,17 @@ export const sendEmptyResponse = (req: Request, res: Response) => {
|
||||
|
||||
res.status(200).send();
|
||||
|
||||
return logResponse(req, res);
|
||||
return logResponse(req, res, undefined);
|
||||
};
|
||||
|
||||
export const sendFileResponse = (req: Request, res: Response, file: File) => {
|
||||
export const sendFileResponse = async (
|
||||
req: Request,
|
||||
res: Response,
|
||||
file: File
|
||||
) => {
|
||||
/** create read stream */
|
||||
|
||||
const gfs = new GridFSBucket(global.client, {
|
||||
const gfs = new GridFSBucket(await Database.getDatabase(), {
|
||||
bucketName: 'uploads',
|
||||
});
|
||||
|
||||
@@ -60,11 +68,9 @@ export const sendErrorResponse = (
|
||||
res: Response,
|
||||
error: Exception
|
||||
) => {
|
||||
let status: Number, message: string;
|
||||
|
||||
res.logBody = { message: error.message }; // To be used in 'auditLog' middleware to log reponse data;
|
||||
status = error.code || 500;
|
||||
message = error.message || 'Server Error';
|
||||
const status: number = error.code || 500;
|
||||
const message: string = error.message || 'Server Error';
|
||||
|
||||
logger.error(error);
|
||||
|
||||
@@ -84,12 +90,12 @@ export const sendListResponse = async (
|
||||
res.set('Request-Id', req.id);
|
||||
res.set('Pod-Id', process.env['POD_NAME']);
|
||||
|
||||
const listData: ListData = {
|
||||
const listData: ListData = new ListData({
|
||||
data: [],
|
||||
count: 0,
|
||||
skip: 0,
|
||||
limit: 0,
|
||||
};
|
||||
});
|
||||
|
||||
if (!list) {
|
||||
list = [];
|
||||
|
||||
@@ -51,7 +51,8 @@ cron.schedule('*/30 * * * *', () => {
|
||||
http.listen(app.get('port'), function () {
|
||||
// eslint-disable-next-line
|
||||
logger.info(
|
||||
`Lighthouse Started on port ${app.get('port')}. OneUptime API URL: ${config.serverUrl
|
||||
`Lighthouse Started on port ${app.get('port')}. OneUptime API URL: ${
|
||||
config.serverUrl
|
||||
}`
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user