mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-06 21:12:34 +02:00
fix formatting...
for fox 🦊 sake 🥴
This commit is contained in:
parent
7cabafebaf
commit
71b89af535
2 changed files with 60 additions and 60 deletions
|
@ -1,5 +1,5 @@
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const {R} = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require("nodemailer");
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class Notification {
|
||||||
} else if (notification.type === "discord") {
|
} else if (notification.type === "discord") {
|
||||||
try {
|
try {
|
||||||
// If heartbeatJSON is null, assume we're testing.
|
// If heartbeatJSON is null, assume we're testing.
|
||||||
if(heartbeatJSON == null) {
|
if (heartbeatJSON == null) {
|
||||||
let data = {
|
let data = {
|
||||||
username: 'Uptime-Kuma',
|
username: 'Uptime-Kuma',
|
||||||
content: msg
|
content: msg
|
||||||
|
@ -64,9 +64,9 @@ class Notification {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// If heartbeatJSON is not null, we go into the normal alerting loop.
|
// If heartbeatJSON is not null, we go into the normal alerting loop.
|
||||||
if(heartbeatJSON['status'] == 0) {
|
if (heartbeatJSON['status'] == 0) {
|
||||||
var alertColor = "16711680";
|
var alertColor = "16711680";
|
||||||
} else if(heartbeatJSON['status'] == 1) {
|
} else if (heartbeatJSON['status'] == 1) {
|
||||||
var alertColor = "65280";
|
var alertColor = "65280";
|
||||||
}
|
}
|
||||||
let data = {
|
let data = {
|
||||||
|
@ -88,7 +88,7 @@ class Notification {
|
||||||
}
|
}
|
||||||
let res = await axios.post(notification.discordWebhookUrl, data)
|
let res = await axios.post(notification.discordWebhookUrl, data)
|
||||||
return true;
|
return true;
|
||||||
} catch(error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ class Notification {
|
||||||
userID,
|
userID,
|
||||||
])
|
])
|
||||||
|
|
||||||
if (! bean) {
|
if (!bean) {
|
||||||
throw new Error("notification not found")
|
throw new Error("notification not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class Notification {
|
||||||
userID,
|
userID,
|
||||||
])
|
])
|
||||||
|
|
||||||
if (! bean) {
|
if (!bean) {
|
||||||
throw new Error("notification not found")
|
throw new Error("notification not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@ const server = http.createServer(app);
|
||||||
const { Server } = require("socket.io");
|
const { Server } = require("socket.io");
|
||||||
const io = new Server(server);
|
const io = new Server(server);
|
||||||
const dayjs = require("dayjs");
|
const dayjs = require("dayjs");
|
||||||
const {R} = require("redbean-node");
|
const { R } = require("redbean-node");
|
||||||
const passwordHash = require('password-hash');
|
const passwordHash = require('password-hash');
|
||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
const Monitor = require("./model/monitor");
|
const Monitor = require("./model/monitor");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const {getSettings} = require("./util-server");
|
const { getSettings } = require("./util-server");
|
||||||
const {Notification} = require("./notification")
|
const { Notification } = require("./notification")
|
||||||
const args = require('args-parser')(process.argv);
|
const args = require('args-parser')(process.argv);
|
||||||
|
|
||||||
const version = require('../package.json').version;
|
const version = require('../package.json').version;
|
||||||
|
@ -30,7 +30,7 @@ let needSetup = false;
|
||||||
|
|
||||||
app.use('/', express.static("dist"));
|
app.use('/', express.static("dist"));
|
||||||
|
|
||||||
app.get('*', function(request, response, next) {
|
app.get('*', function (request, response, next) {
|
||||||
response.sendFile(process.cwd() + '/dist/index.html');
|
response.sendFile(process.cwd() + '/dist/index.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ let needSetup = false;
|
||||||
try {
|
try {
|
||||||
checkLogin(socket)
|
checkLogin(socket)
|
||||||
|
|
||||||
let bean = await R.findOne("monitor", " id = ? ", [ monitor.id ])
|
let bean = await R.findOne("monitor", " id = ? ", [monitor.id])
|
||||||
|
|
||||||
if (bean.user_id !== socket.userID) {
|
if (bean.user_id !== socket.userID) {
|
||||||
throw new Error("Permission denied.")
|
throw new Error("Permission denied.")
|
||||||
|
@ -328,7 +328,7 @@ let needSetup = false;
|
||||||
try {
|
try {
|
||||||
checkLogin(socket)
|
checkLogin(socket)
|
||||||
|
|
||||||
if (! password.currentPassword) {
|
if (!password.currentPassword) {
|
||||||
throw new Error("Invalid new password")
|
throw new Error("Invalid new password")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ async function checkOwner(userID, monitorID) {
|
||||||
userID,
|
userID,
|
||||||
])
|
])
|
||||||
|
|
||||||
if (! row) {
|
if (!row) {
|
||||||
throw new Error("You do not own this monitor.");
|
throw new Error("You do not own this monitor.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -522,7 +522,7 @@ async function getMonitorJSONList(userID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkLogin(socket) {
|
function checkLogin(socket) {
|
||||||
if (! socket.userID) {
|
if (!socket.userID) {
|
||||||
throw new Error("You are not logged in.");
|
throw new Error("You are not logged in.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ function checkLogin(socket) {
|
||||||
async function initDatabase() {
|
async function initDatabase() {
|
||||||
const path = './data/kuma.db';
|
const path = './data/kuma.db';
|
||||||
|
|
||||||
if (! fs.existsSync(path)) {
|
if (!fs.existsSync(path)) {
|
||||||
console.log("Copy Database")
|
console.log("Copy Database")
|
||||||
fs.copyFileSync("./db/kuma.db", path);
|
fs.copyFileSync("./db/kuma.db", path);
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ async function initDatabase() {
|
||||||
"jwtSecret"
|
"jwtSecret"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (! jwtSecretBean) {
|
if (!jwtSecretBean) {
|
||||||
console.log("JWT secret is not found, generate one.")
|
console.log("JWT secret is not found, generate one.")
|
||||||
jwtSecretBean = R.dispense("setting")
|
jwtSecretBean = R.dispense("setting")
|
||||||
jwtSecretBean.key = "jwtSecret"
|
jwtSecretBean.key = "jwtSecret"
|
||||||
|
|
Loading…
Add table
Reference in a new issue