mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix lint.
This commit is contained in:
@@ -11,9 +11,11 @@ const router = express.Router();
|
||||
// get all script monitors for script-runner
|
||||
router.get('/monitors', isAuthorizedService, async (req, res) => {
|
||||
try {
|
||||
|
||||
//get top 10 monitors.
|
||||
const allScriptMonitors = await MonitorService.getScriptMonitors({limit: 10, skip: 0});
|
||||
//get top 10 monitors.
|
||||
const allScriptMonitors = await MonitorService.getScriptMonitors({
|
||||
limit: 10,
|
||||
skip: 0,
|
||||
});
|
||||
|
||||
return sendListResponse(
|
||||
req,
|
||||
|
||||
@@ -80,20 +80,18 @@ function isDate(date) {
|
||||
}
|
||||
|
||||
function logResponse(req, res, responsebody) {
|
||||
|
||||
const requestEndedAt = Date.now();
|
||||
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 - req.requestStartedAt}ms -- STATUS: ${
|
||||
res.statusCode
|
||||
}`;
|
||||
const duration_info = `OUTGOING RESPONSE ID: ${req.id} -- POD NAME: ${
|
||||
process.env.POD_NAME
|
||||
} -- METHOD: ${method} -- URL: ${url} -- DURATION: ${requestEndedAt -
|
||||
req.requestStartedAt}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);
|
||||
@@ -106,7 +104,6 @@ function logResponse(req, res, responsebody) {
|
||||
|
||||
module.exports = {
|
||||
sendEmptyResponse(req, res) {
|
||||
|
||||
res.set('Request-Id', req.id);
|
||||
res.set('Pod-Id', process.env.POD_NAME);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ module.exports = {
|
||||
//Params:
|
||||
//Param 1: data: MonitorModal.
|
||||
//Returns: promise with monitor model or error.
|
||||
create: async function (data) {
|
||||
create: async function(data) {
|
||||
const _this = this;
|
||||
let subProject = null;
|
||||
|
||||
@@ -81,8 +81,8 @@ module.exports = {
|
||||
plan.category === 'Startup'
|
||||
? 5
|
||||
: plan.category === 'Growth'
|
||||
? 10
|
||||
: 0;
|
||||
? 10
|
||||
: 0;
|
||||
if (
|
||||
count < userCount * monitorCount ||
|
||||
!IS_SAAS_SERVICE ||
|
||||
@@ -196,7 +196,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
markMonitorsAsShouldNotMonitor: async function (monitorIds) {
|
||||
markMonitorsAsShouldNotMonitor: async function(monitorIds) {
|
||||
await MonitorModel.updateMany(
|
||||
{
|
||||
_id: { $in: monitorIds },
|
||||
@@ -207,7 +207,7 @@ module.exports = {
|
||||
);
|
||||
},
|
||||
|
||||
markMonitorsAsShouldMonitor: async function (monitorIds) {
|
||||
markMonitorsAsShouldMonitor: async function(monitorIds) {
|
||||
await MonitorModel.updateMany(
|
||||
{
|
||||
_id: { $in: monitorIds },
|
||||
@@ -218,7 +218,7 @@ module.exports = {
|
||||
);
|
||||
},
|
||||
|
||||
unsetColumnsOfManyMonitors: async function (monitorIds, columns) {
|
||||
unsetColumnsOfManyMonitors: async function(monitorIds, columns) {
|
||||
await MonitorModel.updateMany(
|
||||
{
|
||||
_id: { $in: monitorIds },
|
||||
@@ -229,7 +229,7 @@ module.exports = {
|
||||
);
|
||||
},
|
||||
|
||||
updateManyIncidentCommunicationSla: async function (
|
||||
updateManyIncidentCommunicationSla: async function(
|
||||
monitorIds,
|
||||
incidentCommunicationSlaId
|
||||
) {
|
||||
@@ -245,7 +245,7 @@ module.exports = {
|
||||
);
|
||||
},
|
||||
|
||||
updateManyMonitorSla: async function (monitorIds, monitorSlaId) {
|
||||
updateManyMonitorSla: async function(monitorIds, monitorSlaId) {
|
||||
await MonitorModel.updateMany(
|
||||
{
|
||||
_id: { $in: monitorIds },
|
||||
@@ -256,7 +256,7 @@ module.exports = {
|
||||
);
|
||||
},
|
||||
|
||||
updateCriterion: async function (_id, lastMatchedCriterion) {
|
||||
updateCriterion: async function(_id, lastMatchedCriterion) {
|
||||
await MonitorModel.updateOne(
|
||||
{ _id },
|
||||
{ $set: { lastMatchedCriterion } },
|
||||
@@ -266,7 +266,7 @@ module.exports = {
|
||||
);
|
||||
},
|
||||
|
||||
updateLighthouseScanStatus: async function (
|
||||
updateLighthouseScanStatus: async function(
|
||||
_id,
|
||||
lighthouseScanStatus,
|
||||
lighthouseScannedBy
|
||||
@@ -312,7 +312,7 @@ module.exports = {
|
||||
return monitor;
|
||||
},
|
||||
|
||||
disableMonitor: async function (_id, isDisabledOrEnable) {
|
||||
disableMonitor: async function(_id, isDisabledOrEnable) {
|
||||
await MonitorModel.updateOne(
|
||||
{ _id },
|
||||
{
|
||||
@@ -323,7 +323,7 @@ module.exports = {
|
||||
);
|
||||
},
|
||||
|
||||
updateScriptStatus: async function (_id, scriptRunStatus, scriptRunBy) {
|
||||
updateScriptStatus: async function(_id, scriptRunStatus, scriptRunBy) {
|
||||
await MonitorModel.updateOne(
|
||||
{ _id },
|
||||
{
|
||||
@@ -338,7 +338,7 @@ module.exports = {
|
||||
);
|
||||
},
|
||||
|
||||
updateOneBy: async function (query, data, unsetData) {
|
||||
updateOneBy: async function(query, data, unsetData) {
|
||||
const _this = this;
|
||||
|
||||
if (!query) {
|
||||
@@ -428,7 +428,7 @@ module.exports = {
|
||||
return monitor;
|
||||
},
|
||||
|
||||
updateBy: async function (query, data) {
|
||||
updateBy: async function(query, data) {
|
||||
if (!query) {
|
||||
query = {};
|
||||
}
|
||||
@@ -453,7 +453,7 @@ module.exports = {
|
||||
|
||||
// To be used to know the current status of a monitor
|
||||
// online, offline or degraded
|
||||
updateAllMonitorStatus: async function (query, data) {
|
||||
updateAllMonitorStatus: async function(query, data) {
|
||||
if (!query) {
|
||||
query = {};
|
||||
}
|
||||
@@ -527,7 +527,7 @@ module.exports = {
|
||||
return count;
|
||||
},
|
||||
|
||||
deleteBy: async function (query, userId) {
|
||||
deleteBy: async function(query, userId) {
|
||||
if (!query) {
|
||||
query = {};
|
||||
}
|
||||
@@ -1027,7 +1027,8 @@ module.exports = {
|
||||
],
|
||||
},
|
||||
],
|
||||
}).limit(limit)
|
||||
})
|
||||
.limit(limit)
|
||||
.skip(skip);
|
||||
|
||||
// update state of selected script monitors to inProgress
|
||||
@@ -1316,7 +1317,7 @@ module.exports = {
|
||||
return probeStatuses;
|
||||
},
|
||||
|
||||
addSeat: async function (query) {
|
||||
addSeat: async function(query) {
|
||||
const project = await ProjectService.findOneBy({
|
||||
query,
|
||||
select: 'seats stripeSubscriptionId _id',
|
||||
@@ -1339,7 +1340,7 @@ module.exports = {
|
||||
return 'A new seat added. Now you can add a monitor';
|
||||
},
|
||||
|
||||
addSiteUrl: async function (query, data) {
|
||||
addSiteUrl: async function(query, data) {
|
||||
let monitor = await this.findOneBy({ query, select: 'siteUrls' });
|
||||
|
||||
if (
|
||||
@@ -1359,7 +1360,7 @@ module.exports = {
|
||||
return monitor;
|
||||
},
|
||||
|
||||
removeSiteUrl: async function (query, data) {
|
||||
removeSiteUrl: async function(query, data) {
|
||||
let monitor = await this.findOneBy({ query, select: 'siteUrls' });
|
||||
const siteUrlIndex =
|
||||
monitor.siteUrls && monitor.siteUrls.length > 0
|
||||
@@ -1382,7 +1383,7 @@ module.exports = {
|
||||
return monitor;
|
||||
},
|
||||
|
||||
hardDeleteBy: async function (query) {
|
||||
hardDeleteBy: async function(query) {
|
||||
await MonitorModel.deleteMany(query);
|
||||
return 'Monitor(s) removed successfully!';
|
||||
},
|
||||
@@ -1446,14 +1447,14 @@ module.exports = {
|
||||
status = incidents.some(inc =>
|
||||
inc.resolvedAt
|
||||
? moment(inc.resolvedAt)
|
||||
.utc()
|
||||
.startOf('day')
|
||||
.diff(
|
||||
moment(temp.date)
|
||||
.utc()
|
||||
.startOf('day'),
|
||||
'days'
|
||||
) > 0
|
||||
.utc()
|
||||
.startOf('day')
|
||||
.diff(
|
||||
moment(temp.date)
|
||||
.utc()
|
||||
.startOf('day'),
|
||||
'days'
|
||||
) > 0
|
||||
: true
|
||||
)
|
||||
? 'offline'
|
||||
@@ -1471,23 +1472,23 @@ module.exports = {
|
||||
);
|
||||
const resolveddiff = inc.resolvedAt
|
||||
? moment(temp.date)
|
||||
.utc()
|
||||
.startOf('day')
|
||||
.diff(
|
||||
moment(inc.resolvedAt)
|
||||
.utc()
|
||||
.startOf('day'),
|
||||
'days'
|
||||
)
|
||||
.utc()
|
||||
.startOf('day')
|
||||
.diff(
|
||||
moment(inc.resolvedAt)
|
||||
.utc()
|
||||
.startOf('day'),
|
||||
'days'
|
||||
)
|
||||
: moment(temp.date)
|
||||
.utc()
|
||||
.startOf('day')
|
||||
.diff(
|
||||
moment()
|
||||
.utc()
|
||||
.startOf('day'),
|
||||
'days'
|
||||
);
|
||||
.utc()
|
||||
.startOf('day')
|
||||
.diff(
|
||||
moment()
|
||||
.utc()
|
||||
.startOf('day'),
|
||||
'days'
|
||||
);
|
||||
if (creatediff > 0 && resolveddiff < 0) {
|
||||
return 1440;
|
||||
} else if (creatediff === 0 && resolveddiff !== 0) {
|
||||
@@ -1522,7 +1523,7 @@ module.exports = {
|
||||
return times;
|
||||
},
|
||||
|
||||
restoreBy: async function (query) {
|
||||
restoreBy: async function(query) {
|
||||
const _this = this;
|
||||
query.deleted = true;
|
||||
const select = '_id';
|
||||
@@ -1558,7 +1559,7 @@ module.exports = {
|
||||
|
||||
// checks if the monitor uptime stat is within the defined uptime on monitor sla
|
||||
// then update the monitor => breachedMonitorSla
|
||||
updateMonitorSlaStat: async function (query) {
|
||||
updateMonitorSlaStat: async function(query) {
|
||||
const _this = this;
|
||||
const currentDate = moment().format();
|
||||
let startDate = moment(currentDate).subtract(30, 'days'); // default frequency
|
||||
@@ -1647,7 +1648,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
calculateTime: function (statuses, start, range) {
|
||||
calculateTime: function(statuses, start, range) {
|
||||
const timeBlock = [];
|
||||
let totalUptime = 0;
|
||||
let totalTime = 0;
|
||||
@@ -1714,8 +1715,8 @@ module.exports = {
|
||||
moment(a.start).isSame(b.start)
|
||||
? 0
|
||||
: moment(a.start).isAfter(b.start)
|
||||
? 1
|
||||
: -1
|
||||
? 1
|
||||
: -1
|
||||
);
|
||||
//Third step
|
||||
for (let i = 0; i < incidentsHappenedDuringTheDay.length - 1; i++) {
|
||||
@@ -1851,7 +1852,7 @@ module.exports = {
|
||||
return { timeBlock, uptimePercent: (totalUptime / totalTime) * 100 };
|
||||
},
|
||||
|
||||
closeBreachedMonitorSla: async function (projectId, monitorId, userId) {
|
||||
closeBreachedMonitorSla: async function(projectId, monitorId, userId) {
|
||||
const monitor = await MonitorModel.findOneAndUpdate(
|
||||
{
|
||||
_id: monitorId,
|
||||
@@ -1868,7 +1869,7 @@ module.exports = {
|
||||
return monitor;
|
||||
},
|
||||
|
||||
changeMonitorComponent: async function (projectId, monitorId, componentId) {
|
||||
changeMonitorComponent: async function(projectId, monitorId, componentId) {
|
||||
const [monitor, component] = await Promise.all([
|
||||
this.findOneBy({
|
||||
query: { _id: monitorId },
|
||||
@@ -1898,7 +1899,7 @@ module.exports = {
|
||||
return updatedMonitor;
|
||||
},
|
||||
|
||||
calcTime: function (statuses, start, range) {
|
||||
calcTime: function(statuses, start, range) {
|
||||
const timeBlock = [];
|
||||
let totalUptime = 0;
|
||||
let totalTime = 0;
|
||||
@@ -1993,8 +1994,8 @@ module.exports = {
|
||||
moment(a.start).isSame(b.start)
|
||||
? 0
|
||||
: moment(a.start).isAfter(b.start)
|
||||
? 1
|
||||
: -1
|
||||
? 1
|
||||
: -1
|
||||
);
|
||||
//Third step
|
||||
for (let i = 0; i < incidentsHappenedDuringTheDay.length - 1; i++) {
|
||||
|
||||
@@ -127,10 +127,14 @@ app.use(async function(req, res, next) {
|
||||
req.logdata = logdata;
|
||||
|
||||
logger.info(
|
||||
`INCOMING REQUEST ID: ${req.id} -- POD NAME: ${process.env.POD_NAME} -- RECEIVED AT: ${new Date()} -- METHOD: ${method} -- URL: ${url}`
|
||||
`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'
|
||||
}`
|
||||
);
|
||||
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user