diff --git a/server/auth.js b/server/auth.js
index b4d13d68a..54182bdef 100644
--- a/server/auth.js
+++ b/server/auth.js
@@ -1,6 +1,6 @@
-const basicAuth = require('express-basic-auth')
-const passwordHash = require('./password-hash');
-const {R} = require("redbean-node");
+const basicAuth = require("express-basic-auth")
+const passwordHash = require("./password-hash");
+const { R } = require("redbean-node");
/**
*
@@ -10,7 +10,7 @@ const {R} = require("redbean-node");
*/
exports.login = async function (username, password) {
let user = await R.findOne("user", " username = ? AND active = 1 ", [
- username
+ username,
])
if (user && passwordHash.verify(password, user.password)) {
@@ -18,13 +18,13 @@ exports.login = async function (username, password) {
if (passwordHash.needRehash(user.password)) {
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
passwordHash.generate(password),
- user.id
+ user.id,
]);
}
return user;
- } else {
- return null;
}
+
+ return null;
}
function myAuthorizer(username, password, callback) {
@@ -36,5 +36,5 @@ function myAuthorizer(username, password, callback) {
exports.basicAuth = basicAuth({
authorizer: myAuthorizer,
authorizeAsync: true,
- challenge: true
+ challenge: true,
});
diff --git a/server/model/heartbeat.js b/server/model/heartbeat.js
index 01fb71ff9..0e492ada1 100644
--- a/server/model/heartbeat.js
+++ b/server/model/heartbeat.js
@@ -1,10 +1,9 @@
const dayjs = require("dayjs");
-const utc = require('dayjs/plugin/utc')
-var timezone = require('dayjs/plugin/timezone')
+const utc = require("dayjs/plugin/utc")
+let timezone = require("dayjs/plugin/timezone")
dayjs.extend(utc)
dayjs.extend(timezone)
-const {BeanModel} = require("redbean-node/dist/bean-model");
-
+const { BeanModel } = require("redbean-node/dist/bean-model");
/**
* status:
diff --git a/server/notification.js b/server/notification.js
index 9da8a0dc8..f4cd08af9 100644
--- a/server/notification.js
+++ b/server/notification.js
@@ -1,6 +1,6 @@
const axios = require("axios");
-const {R} = require("redbean-node");
-const FormData = require('form-data');
+const { R } = require("redbean-node");
+const FormData = require("form-data");
const nodemailer = require("nodemailer");
const child_process = require("child_process");
@@ -24,7 +24,7 @@ class Notification {
params: {
chat_id: notification.telegramChatID,
text: msg,
- }
+ },
})
return okMsg;
@@ -41,7 +41,7 @@ class Notification {
await axios.post(`${notification.gotifyserverurl}/message?token=${notification.gotifyapplicationToken}`, {
"message": msg,
"priority": notification.gotifyPriority || 8,
- "title": "Uptime-Kuma"
+ "title": "Uptime-Kuma",
})
return okMsg;
@@ -62,10 +62,10 @@ class Notification {
if (notification.webhookContentType === "form-data") {
finalData = new FormData();
- finalData.append('data', JSON.stringify(data));
+ finalData.append("data", JSON.stringify(data));
config = {
- headers: finalData.getHeaders()
+ headers: finalData.getHeaders(),
}
} else {
@@ -84,63 +84,68 @@ class Notification {
} else if (notification.type === "discord") {
try {
- // If heartbeatJSON is null, assume we're testing.
- if(heartbeatJSON == null) {
+ // If heartbeatJSON is null, assume we're testing.
+ if (heartbeatJSON == null) {
+ let data = {
+ username: "Uptime-Kuma",
+ content: msg,
+ }
+ await axios.post(notification.discordWebhookUrl, data)
+ return okMsg;
+ }
+ // If heartbeatJSON is not null, we go into the normal alerting loop.
+ if (heartbeatJSON["status"] == 0) {
+ var alertColor = "16711680";
+ } else if (heartbeatJSON["status"] == 1) {
+ var alertColor = "65280";
+ }
let data = {
- username: 'Uptime-Kuma',
- content: msg
+ username: "Uptime-Kuma",
+ embeds: [{
+ title: "Uptime-Kuma Alert",
+ color: alertColor,
+ fields: [
+ {
+ name: "Time (UTC)",
+ value: heartbeatJSON["time"],
+ },
+ {
+ name: "Message",
+ value: msg,
+ },
+ ],
+ }],
}
await axios.post(notification.discordWebhookUrl, data)
return okMsg;
- }
- // If heartbeatJSON is not null, we go into the normal alerting loop.
- if(heartbeatJSON['status'] == 0) {
- var alertColor = "16711680";
- } else if(heartbeatJSON['status'] == 1) {
- var alertColor = "65280";
- }
- let data = {
- username: 'Uptime-Kuma',
- embeds: [{
- title: "Uptime-Kuma Alert",
- color: alertColor,
- fields: [
- {
- name: "Time (UTC)",
- value: heartbeatJSON["time"]
- },
- {
- name: "Message",
- value: msg
- }
- ]
- }]
- }
- await axios.post(notification.discordWebhookUrl, data)
- return okMsg;
- } catch(error) {
- throwGeneralAxiosError(error)
+ } catch (error) {
+ throwGeneralAxiosError(error)
}
} else if (notification.type === "signal") {
- try {
- let data = {
- "message": msg,
- "number": notification.signalNumber,
- "recipients": notification.signalRecipients.replace(/\s/g, '').split(",")
- };
- let config = {};
+ try {
+ let data = {
+ "message": msg,
+ "number": notification.signalNumber,
+ "recipients": notification.signalRecipients.replace(/\s/g, "").split(","),
+ };
+ let config = {};
- await axios.post(notification.signalURL, data, config)
- return okMsg;
- } catch (error) {
- throwGeneralAxiosError(error)
- }
+ await axios.post(notification.signalURL, data, config)
+ return okMsg;
+ } catch (error) {
+ throwGeneralAxiosError(error)
+ }
} else if (notification.type === "slack") {
try {
if (heartbeatJSON == null) {
- let data = {'text': "Uptime Kuma Slack testing successful.", 'channel': notification.slackchannel, 'username': notification.slackusername, 'icon_emoji': notification.slackiconemo}
+ let data = {
+ "text": "Uptime Kuma Slack testing successful.",
+ "channel": notification.slackchannel,
+ "username": notification.slackusername,
+ "icon_emoji": notification.slackiconemo,
+ }
await axios.post(notification.slackwebhookURL, data)
return okMsg;
}
@@ -148,44 +153,42 @@ class Notification {
const time = heartbeatJSON["time"];
let data = {
"text": "Uptime Kuma Alert",
- "channel":notification.slackchannel,
+ "channel": notification.slackchannel,
"username": notification.slackusername,
"icon_emoji": notification.slackiconemo,
"blocks": [{
- "type": "header",
- "text": {
- "type": "plain_text",
- "text": "Uptime Kuma Alert"
- }
+ "type": "header",
+ "text": {
+ "type": "plain_text",
+ "text": "Uptime Kuma Alert",
+ },
+ },
+ {
+ "type": "section",
+ "fields": [{
+ "type": "mrkdwn",
+ "text": "*Message*\n" + msg,
},
{
- "type": "section",
- "fields": [{
- "type": "mrkdwn",
- "text": '*Message*\n'+msg
+ "type": "mrkdwn",
+ "text": "*Time (UTC)*\n" + time,
+ }],
+ },
+ {
+ "type": "actions",
+ "elements": [
+ {
+ "type": "button",
+ "text": {
+ "type": "plain_text",
+ "text": "Visit Uptime Kuma",
},
- {
- "type": "mrkdwn",
- "text": "*Time (UTC)*\n"+time
- }
- ]
- },
- {
- "type": "actions",
- "elements": [
- {
- "type": "button",
- "text": {
- "type": "plain_text",
- "text": "Visit Uptime Kuma",
- },
- "value": "Uptime-Kuma",
- "url": notification.slackbutton || "https://github.com/louislam/uptime-kuma"
- }
- ]
- }
- ]
- }
+ "value": "Uptime-Kuma",
+ "url": notification.slackbutton || "https://github.com/louislam/uptime-kuma",
+ },
+ ],
+ }],
+ }
await axios.post(notification.slackwebhookURL, data)
return okMsg;
} catch (error) {
@@ -193,27 +196,35 @@ class Notification {
}
} else if (notification.type === "pushover") {
- var pushoverlink = 'https://api.pushover.net/1/messages.json'
+ let pushoverlink = "https://api.pushover.net/1/messages.json"
try {
if (heartbeatJSON == null) {
- let data = {'message': "Uptime Kuma Pushover testing successful.",
- 'user': notification.pushoveruserkey, 'token': notification.pushoverapptoken, 'sound':notification.pushoversounds,
- 'priority': notification.pushoverpriority, 'title':notification.pushovertitle, 'retry': "30", 'expire':"3600", 'html': 1}
+ let data = {
+ "message": "Uptime Kuma Pushover testing successful.",
+ "user": notification.pushoveruserkey,
+ "token": notification.pushoverapptoken,
+ "sound": notification.pushoversounds,
+ "priority": notification.pushoverpriority,
+ "title": notification.pushovertitle,
+ "retry": "30",
+ "expire": "3600",
+ "html": 1,
+ }
await axios.post(pushoverlink, data)
return okMsg;
}
let data = {
- "message": "Uptime Kuma Alert\n\nMessage:"+msg+ '\nTime (UTC):' +heartbeatJSON["time"],
- "user":notification.pushoveruserkey,
+ "message": "Uptime Kuma Alert\n\nMessage:" + msg + "\nTime (UTC):" + heartbeatJSON["time"],
+ "user": notification.pushoveruserkey,
"token": notification.pushoverapptoken,
"sound": notification.pushoversounds,
"priority": notification.pushoverpriority,
"title": notification.pushovertitle,
"retry": "30",
"expire": "3600",
- "html": 1
- }
+ "html": 1,
+ }
await axios.post(pushoverlink, data)
return okMsg;
} catch (error) {
@@ -291,24 +302,23 @@ class Notification {
static async apprise(notification, msg) {
let s = child_process.spawnSync("apprise", [ "-vv", "-b", msg, notification.appriseURL])
-
- let output = (s.stdout) ? s.stdout.toString() : 'ERROR: maybe apprise not found';
+ let output = (s.stdout) ? s.stdout.toString() : "ERROR: maybe apprise not found";
if (output) {
if (! output.includes("ERROR")) {
return "Sent Successfully";
- } else {
- throw new Error(output)
}
+ throw new Error(output)
+
} else {
return ""
}
}
static checkApprise() {
- let commandExistsSync = require('command-exists').sync;
- let exists = commandExistsSync('apprise');
+ let commandExistsSync = require("command-exists").sync;
+ let exists = commandExistsSync("apprise");
return exists;
}
diff --git a/server/password-hash.js b/server/password-hash.js
index 39bc0c20c..52e26b959 100644
--- a/server/password-hash.js
+++ b/server/password-hash.js
@@ -1,5 +1,5 @@
-const passwordHashOld = require('password-hash');
-const bcrypt = require('bcrypt');
+const passwordHashOld = require("password-hash");
+const bcrypt = require("bcrypt");
const saltRounds = 10;
exports.generate = function (password) {
@@ -9,9 +9,9 @@ exports.generate = function (password) {
exports.verify = function (password, hash) {
if (isSHA1(hash)) {
return passwordHashOld.verify(password, hash)
- } else {
- return bcrypt.compareSync(password, hash);
}
+
+ return bcrypt.compareSync(password, hash);
}
function isSHA1(hash) {
diff --git a/server/ping-lite.js b/server/ping-lite.js
index e290d8876..337bc0d3d 100644
--- a/server/ping-lite.js
+++ b/server/ping-lite.js
@@ -1,9 +1,9 @@
// https://github.com/ben-bradley/ping-lite/blob/master/ping-lite.js
// Fixed on Windows
-var spawn = require('child_process').spawn,
- events = require('events'),
- fs = require('fs'),
+let spawn = require("child_process").spawn,
+ events = require("events"),
+ fs = require("fs"),
WIN = /^win/.test(process.platform),
LIN = /^linux/.test(process.platform),
MAC = /^darwin/.test(process.platform);
@@ -11,8 +11,9 @@ var spawn = require('child_process').spawn,
module.exports = Ping;
function Ping(host, options) {
- if (!host)
- throw new Error('You must specify a host to ping!');
+ if (!host) {
+ throw new Error("You must specify a host to ping!");
+ }
this._host = host;
this._options = options = (options || {});
@@ -20,26 +21,24 @@ function Ping(host, options) {
events.EventEmitter.call(this);
if (WIN) {
- this._bin = 'c:/windows/system32/ping.exe';
- this._args = (options.args) ? options.args : [ '-n', '1', '-w', '5000', host ];
+ this._bin = "c:/windows/system32/ping.exe";
+ this._args = (options.args) ? options.args : [ "-n", "1", "-w", "5000", host ];
this._regmatch = /[><=]([0-9.]+?)ms/;
- }
- else if (LIN) {
- this._bin = '/bin/ping';
- this._args = (options.args) ? options.args : [ '-n', '-w', '2', '-c', '1', host ];
+ } else if (LIN) {
+ this._bin = "/bin/ping";
+ this._args = (options.args) ? options.args : [ "-n", "-w", "2", "-c", "1", host ];
this._regmatch = /=([0-9.]+?) ms/; // need to verify this
- }
- else if (MAC) {
- this._bin = '/sbin/ping';
- this._args = (options.args) ? options.args : [ '-n', '-t', '2', '-c', '1', host ];
+ } else if (MAC) {
+ this._bin = "/sbin/ping";
+ this._args = (options.args) ? options.args : [ "-n", "-t", "2", "-c", "1", host ];
this._regmatch = /=([0-9.]+?) ms/;
- }
- else {
- throw new Error('Could not detect your ping binary.');
+ } else {
+ throw new Error("Could not detect your ping binary.");
}
- if (!fs.existsSync(this._bin))
- throw new Error('Could not detect '+this._bin+' on your system');
+ if (!fs.existsSync(this._bin)) {
+ throw new Error("Could not detect " + this._bin + " on your system");
+ }
this._i = 0;
@@ -51,48 +50,56 @@ Ping.prototype.__proto__ = events.EventEmitter.prototype;
// SEND A PING
// ===========
Ping.prototype.send = function(callback) {
- var self = this;
+ let self = this;
callback = callback || function(err, ms) {
- if (err) return self.emit('error', err);
- else return self.emit('result', ms);
+ if (err) {
+ return self.emit("error", err);
+ }
+ return self.emit("result", ms);
};
- var _ended, _exited, _errored;
+ let _ended, _exited, _errored;
this._ping = spawn(this._bin, this._args); // spawn the binary
- this._ping.on('error', function(err) { // handle binary errors
+ this._ping.on("error", function(err) { // handle binary errors
_errored = true;
callback(err);
});
- this._ping.stdout.on('data', function(data) { // log stdout
- this._stdout = (this._stdout || '') + data;
+ this._ping.stdout.on("data", function(data) { // log stdout
+ this._stdout = (this._stdout || "") + data;
});
- this._ping.stdout.on('end', function() {
+ this._ping.stdout.on("end", function() {
_ended = true;
- if (_exited && !_errored) onEnd.call(self._ping);
+ if (_exited && !_errored) {
+ onEnd.call(self._ping);
+ }
});
- this._ping.stderr.on('data', function(data) { // log stderr
- this._stderr = (this._stderr || '') + data;
+ this._ping.stderr.on("data", function(data) { // log stderr
+ this._stderr = (this._stderr || "") + data;
});
- this._ping.on('exit', function(code) { // handle complete
+ this._ping.on("exit", function(code) { // handle complete
_exited = true;
- if (_ended && !_errored) onEnd.call(self._ping);
+ if (_ended && !_errored) {
+ onEnd.call(self._ping);
+ }
});
function onEnd() {
- var stdout = this.stdout._stdout,
+ let stdout = this.stdout._stdout,
stderr = this.stderr._stderr,
ms;
- if (stderr)
+ if (stderr) {
return callback(new Error(stderr));
- else if (!stdout)
- return callback(new Error('No stdout detected'));
+ }
+ if (!stdout) {
+ return callback(new Error("No stdout detected"));
+ }
ms = stdout.match(self._regmatch); // parse out the ##ms response
ms = (ms && ms[1]) ? Number(ms[1]) : ms;
@@ -104,7 +111,7 @@ Ping.prototype.send = function(callback) {
// CALL Ping#send(callback) ON A TIMER
// ===================================
Ping.prototype.start = function(callback) {
- var self = this;
+ let self = this;
this._i = setInterval(function() {
self.send(callback);
}, (self._options.interval || 5000));
diff --git a/server/server.js b/server/server.js
index 2014d927f..5b76b7966 100644
--- a/server/server.js
+++ b/server/server.js
@@ -1,23 +1,23 @@
console.log("Welcome to Uptime Kuma ")
console.log("Importing libraries")
-const express = require('express');
-const http = require('http');
+const express = require("express");
+const http = require("http");
const { Server } = require("socket.io");
const dayjs = require("dayjs");
-const {R} = require("redbean-node");
-const jwt = require('jsonwebtoken');
+const { R } = require("redbean-node");
+const jwt = require("jsonwebtoken");
const Monitor = require("./model/monitor");
const fs = require("fs");
-const {getSettings} = require("./util-server");
-const {Notification} = require("./notification")
-const gracefulShutdown = require('http-graceful-shutdown');
+const { getSettings } = require("./util-server");
+const { Notification } = require("./notification")
+const gracefulShutdown = require("http-graceful-shutdown");
const Database = require("./database");
-const {sleep} = require("./util");
-const args = require('args-parser')(process.argv);
-const prometheusAPIMetrics = require('prometheus-api-metrics');
+const { sleep } = require("./util");
+const args = require("args-parser")(process.argv);
+const prometheusAPIMetrics = require("prometheus-api-metrics");
const { basicAuth } = require("./auth");
-const {login} = require("./auth");
-const version = require('../package.json').version;
+const { login } = require("./auth");
+const version = require("../package.json").version;
const hostname = args.host || "0.0.0.0"
const port = args.port || 3001
@@ -63,12 +63,12 @@ let needSetup = false;
// Normal Router here
- app.use('/', express.static("dist"));
+ app.use("/", express.static("dist"));
// Basic Auth Router here
// For testing
- basicAuthRouter.get('/test-auth', (req, res) => {
+ basicAuthRouter.get("/test-auth", (req, res) => {
res.end("OK")
});
@@ -77,12 +77,12 @@ let needSetup = false;
basicAuthRouter.use(prometheusAPIMetrics())
// Universal Route Handler, must be at the end
- app.get('*', function(request, response, next) {
- response.sendFile(process.cwd() + '/dist/index.html');
+ app.get("*", function(request, response, next) {
+ response.sendFile(process.cwd() + "/dist/index.html");
});
console.log("Adding socket handler")
- io.on('connection', async (socket) => {
+ io.on("connection", async (socket) => {
socket.emit("info", {
version,
@@ -95,7 +95,7 @@ let needSetup = false;
socket.emit("setup")
}
- socket.on('disconnect', () => {
+ socket.on("disconnect", () => {
totalClient--;
});
@@ -109,7 +109,7 @@ let needSetup = false;
console.log("Username from JWT: " + decoded.username)
let user = await R.findOne("user", " username = ? AND active = 1 ", [
- decoded.username
+ decoded.username,
])
if (user) {
@@ -121,13 +121,13 @@ let needSetup = false;
} else {
callback({
ok: false,
- msg: "The user is inactive or deleted."
+ msg: "The user is inactive or deleted.",
})
}
} catch (error) {
callback({
ok: false,
- msg: "Invalid token."
+ msg: "Invalid token.",
})
}
@@ -144,13 +144,13 @@ let needSetup = false;
callback({
ok: true,
token: jwt.sign({
- username: data.username
- }, jwtSecret)
+ username: data.username,
+ }, jwtSecret),
})
} else {
callback({
ok: false,
- msg: "Incorrect username or password."
+ msg: "Incorrect username or password.",
})
}
@@ -181,13 +181,13 @@ let needSetup = false;
callback({
ok: true,
- msg: "Added Successfully."
+ msg: "Added Successfully.",
});
} catch (e) {
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -214,13 +214,13 @@ let needSetup = false;
callback({
ok: true,
msg: "Added Successfully.",
- monitorID: bean.id
+ monitorID: bean.id,
});
} catch (e) {
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -257,14 +257,14 @@ let needSetup = false;
callback({
ok: true,
msg: "Saved.",
- monitorID: bean.id
+ monitorID: bean.id,
});
} catch (e) {
console.error(e)
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -288,7 +288,7 @@ let needSetup = false;
} catch (e) {
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -302,13 +302,13 @@ let needSetup = false;
callback({
ok: true,
- msg: "Resumed Successfully."
+ msg: "Resumed Successfully.",
});
} catch (e) {
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -321,14 +321,13 @@ let needSetup = false;
callback({
ok: true,
- msg: "Paused Successfully."
+ msg: "Paused Successfully.",
});
-
} catch (e) {
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -346,12 +345,12 @@ let needSetup = false;
await R.exec("DELETE FROM monitor WHERE id = ? AND user_id = ? ", [
monitorID,
- socket.userID
+ socket.userID,
]);
callback({
ok: true,
- msg: "Deleted Successfully."
+ msg: "Deleted Successfully.",
});
await sendMonitorList(socket);
@@ -359,7 +358,7 @@ let needSetup = false;
} catch (e) {
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -373,19 +372,19 @@ let needSetup = false;
}
let user = await R.findOne("user", " id = ? AND active = 1 ", [
- socket.userID
+ socket.userID,
])
if (user && passwordHash.verify(password.currentPassword, user.password)) {
await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
passwordHash.generate(password.newPassword),
- socket.userID
+ socket.userID,
]);
callback({
ok: true,
- msg: "Password has been updated successfully."
+ msg: "Password has been updated successfully.",
})
} else {
throw new Error("Incorrect current password")
@@ -394,7 +393,7 @@ let needSetup = false;
} catch (e) {
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -403,7 +402,6 @@ let needSetup = false;
try {
checkLogin(socket)
-
callback({
ok: true,
data: await getSettings(type),
@@ -412,7 +410,7 @@ let needSetup = false;
} catch (e) {
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -433,7 +431,7 @@ let needSetup = false;
} catch (e) {
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -453,7 +451,7 @@ let needSetup = false;
} catch (e) {
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -466,7 +464,7 @@ let needSetup = false;
callback({
ok: true,
- msg
+ msg,
});
} catch (e) {
@@ -474,7 +472,7 @@ let needSetup = false;
callback({
ok: false,
- msg: e.message
+ msg: e.message,
});
}
});
@@ -499,7 +497,7 @@ let needSetup = false;
async function updateMonitorNotification(monitorID, notificationIDList) {
R.exec("DELETE FROM monitor_notification WHERE monitor_id = ? ", [
- monitorID
+ monitorID,
])
for (let notificationID in notificationIDList) {
@@ -532,7 +530,7 @@ async function sendMonitorList(socket) {
async function sendNotificationList(socket) {
let result = [];
let list = await R.find("notification", " user_id = ? ", [
- socket.userID
+ socket.userID,
]);
for (let bean of list) {
@@ -562,7 +560,7 @@ async function getMonitorJSONList(userID) {
let result = {};
let monitorList = await R.find("monitor", " user_id = ? ", [
- userID
+ userID,
])
for (let monitor of monitorList) {
@@ -585,8 +583,8 @@ async function initDatabase() {
}
console.log("Connecting to Database")
- R.setup('sqlite', {
- filename: Database.path
+ R.setup("sqlite", {
+ filename: Database.path,
});
console.log("Connected")
@@ -598,7 +596,7 @@ async function initDatabase() {
await R.autoloadModels("./server/model");
let jwtSecretBean = await R.findOne("setting", " `key` = ? ", [
- "jwtSecret"
+ "jwtSecret",
]);
if (! jwtSecretBean) {
@@ -629,11 +627,11 @@ async function startMonitor(userID, monitorID) {
await R.exec("UPDATE monitor SET active = 1 WHERE id = ? AND user_id = ? ", [
monitorID,
- userID
+ userID,
]);
let monitor = await R.findOne("monitor", " id = ? ", [
- monitorID
+ monitorID,
])
if (monitor.id in monitorList) {
@@ -655,7 +653,7 @@ async function pauseMonitor(userID, monitorID) {
await R.exec("UPDATE monitor SET active = 0 WHERE id = ? AND user_id = ? ", [
monitorID,
- userID
+ userID,
]);
if (monitorID in monitorList) {
@@ -684,13 +682,13 @@ async function sendHeartbeatList(socket, monitorID) {
ORDER BY time DESC
LIMIT 100
`, [
- monitorID
+ monitorID,
])
let result = [];
for (let bean of list) {
- result.unshift(bean.toJSON())
+ result.unshift(bean.toJSON())
}
socket.emit("heartbeatList", monitorID, result)
@@ -703,23 +701,20 @@ async function sendImportantHeartbeatList(socket, monitorID) {
ORDER BY time DESC
LIMIT 500
`, [
- monitorID
+ monitorID,
])
socket.emit("importantHeartbeatList", monitorID, list)
}
-
-
const startGracefulShutdown = async () => {
- console.log('Shutdown requested');
-
+ console.log("Shutdown requested");
await (new Promise((resolve) => {
server.close(async function () {
- console.log('Stopped Express.');
+ console.log("Stopped Express.");
process.exit(0)
- setTimeout(async () =>{
+ setTimeout(async () => {
await R.close();
console.log("Stopped DB")
@@ -729,11 +724,10 @@ const startGracefulShutdown = async () => {
});
}));
-
}
async function shutdownFunction(signal) {
- console.log('Called signal: ' + signal);
+ console.log("Called signal: " + signal);
console.log("Stopping all monitors")
for (let id in monitorList) {
@@ -745,14 +739,14 @@ async function shutdownFunction(signal) {
}
function finalFunction() {
- console.log('Graceful Shutdown')
+ console.log("Graceful Shutdown")
}
gracefulShutdown(server, {
- signals: 'SIGINT SIGTERM',
+ signals: "SIGINT SIGTERM",
timeout: 30000, // timeout: 30 secs
development: false, // not in dev mode
forceExit: true, // triggers process.exit() at the end of shutdown process
onShutdown: shutdownFunction, // shutdown function (async) - e.g. for cleanup DB, ...
- finally: finalFunction // finally function (sync) - e.g. for logging
+ finally: finalFunction, // finally function (sync) - e.g. for logging
});
diff --git a/server/util-server.js b/server/util-server.js
index f03823d3a..43aa5ccfb 100644
--- a/server/util-server.js
+++ b/server/util-server.js
@@ -1,6 +1,6 @@
-const tcpp = require('tcp-ping');
+const tcpp = require("tcp-ping");
const Ping = require("./ping-lite");
-const {R} = require("redbean-node");
+const { R } = require("redbean-node");
exports.tcping = function (hostname, port) {
return new Promise((resolve, reject) => {
@@ -41,13 +41,13 @@ exports.ping = function (hostname) {
exports.setting = async function (key) {
return await R.getCell("SELECT `value` FROM setting WHERE `key` = ? ", [
- key
+ key,
])
}
exports.setSetting = async function (key, value) {
let bean = await R.findOne("setting", " `key` = ? ", [
- key
+ key,
])
if (! bean) {
bean = R.dispense("setting")
@@ -59,7 +59,7 @@ exports.setSetting = async function (key, value) {
exports.getSettings = async function (type) {
let list = await R.getAll("SELECT * FROM setting WHERE `type` = ? ", [
- type
+ type,
])
let result = {};
@@ -71,7 +71,6 @@ exports.getSettings = async function (type) {
return result;
}
-
// ssl-checker by @dyaa
// param: res - response object from axios
// return an object containing the certificate information
@@ -97,7 +96,9 @@ exports.checkCertificate = function (res) {
} = res.request.res.socket.getPeerCertificate(false);
if (!valid_from || !valid_to || !subjectaltname) {
- throw { message: 'No TLS certificate in response' };
+ throw {
+ message: "No TLS certificate in response",
+ };
}
const valid = res.request.res.socket.authorized || false;
@@ -118,4 +119,4 @@ exports.checkCertificate = function (res) {
issuer,
fingerprint,
};
-}
\ No newline at end of file
+}
diff --git a/server/util.js b/server/util.js
index 081561bf9..6e90dc42b 100644
--- a/server/util.js
+++ b/server/util.js
@@ -23,4 +23,3 @@ exports.debug = (msg) => {
console.log(msg)
}
}
-
diff --git a/src/App.vue b/src/App.vue
index 1f05560e6..974757a63 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -3,9 +3,7 @@