|
|
@ -1,25 +1,45 @@
|
|
|
|
console.log("Welcome to Uptime Kuma ")
|
|
|
|
console.log("Welcome to Uptime Kuma")
|
|
|
|
console.log("Importing libraries")
|
|
|
|
|
|
|
|
const express = require("express");
|
|
|
|
const { sleep, debug } = require("../src/util");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("Importing Node libraries")
|
|
|
|
|
|
|
|
const fs = require("fs");
|
|
|
|
const http = require("http");
|
|
|
|
const http = require("http");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("Importing 3rd-party libraries")
|
|
|
|
|
|
|
|
debug("Importing express");
|
|
|
|
|
|
|
|
const express = require("express");
|
|
|
|
|
|
|
|
debug("Importing socket.io");
|
|
|
|
const { Server } = require("socket.io");
|
|
|
|
const { Server } = require("socket.io");
|
|
|
|
|
|
|
|
debug("Importing dayjs");
|
|
|
|
const dayjs = require("dayjs");
|
|
|
|
const dayjs = require("dayjs");
|
|
|
|
|
|
|
|
debug("Importing redbean-node");
|
|
|
|
const { R } = require("redbean-node");
|
|
|
|
const { R } = require("redbean-node");
|
|
|
|
|
|
|
|
debug("Importing jsonwebtoken");
|
|
|
|
const jwt = require("jsonwebtoken");
|
|
|
|
const jwt = require("jsonwebtoken");
|
|
|
|
const Monitor = require("./model/monitor");
|
|
|
|
debug("Importing http-graceful-shutdown");
|
|
|
|
const fs = require("fs");
|
|
|
|
|
|
|
|
const { getSettings } = require("./util-server");
|
|
|
|
|
|
|
|
const { Notification } = require("./notification")
|
|
|
|
|
|
|
|
const gracefulShutdown = require("http-graceful-shutdown");
|
|
|
|
const gracefulShutdown = require("http-graceful-shutdown");
|
|
|
|
const Database = require("./database");
|
|
|
|
debug("Importing prometheus-api-metrics");
|
|
|
|
const { sleep } = require("../src/util");
|
|
|
|
|
|
|
|
const args = require("args-parser")(process.argv);
|
|
|
|
|
|
|
|
const prometheusAPIMetrics = require("prometheus-api-metrics");
|
|
|
|
const prometheusAPIMetrics = require("prometheus-api-metrics");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("Importing this project modules");
|
|
|
|
|
|
|
|
debug("Importing Monitor");
|
|
|
|
|
|
|
|
const Monitor = require("./model/monitor");
|
|
|
|
|
|
|
|
debug("Importing Settings");
|
|
|
|
|
|
|
|
const { getSettings, setSettings } = require("./util-server");
|
|
|
|
|
|
|
|
debug("Importing Notification");
|
|
|
|
|
|
|
|
const { Notification } = require("./notification");
|
|
|
|
|
|
|
|
debug("Importing Database");
|
|
|
|
|
|
|
|
const Database = require("./database");
|
|
|
|
|
|
|
|
|
|
|
|
const { basicAuth } = require("./auth");
|
|
|
|
const { basicAuth } = require("./auth");
|
|
|
|
const { login } = require("./auth");
|
|
|
|
const { login } = require("./auth");
|
|
|
|
const passwordHash = require("./password-hash");
|
|
|
|
const passwordHash = require("./password-hash");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const args = require("args-parser")(process.argv);
|
|
|
|
|
|
|
|
|
|
|
|
const version = require("../package.json").version;
|
|
|
|
const version = require("../package.json").version;
|
|
|
|
const hostname = args.host || "0.0.0.0"
|
|
|
|
const hostname = process.env.HOST || args.host || "0.0.0.0"
|
|
|
|
const port = parseInt(process.env.PORT || args.port || 3001);
|
|
|
|
const port = parseInt(process.env.PORT || args.port || 3001);
|
|
|
|
|
|
|
|
|
|
|
|
console.info("Version: " + version)
|
|
|
|
console.info("Version: " + version)
|
|
|
@ -405,13 +425,32 @@ let indexHTML = fs.readFileSync("./dist/index.html").toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
socket.on("getSettings", async (type, callback) => {
|
|
|
|
socket.on("getSettings", async (callback) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
checkLogin(socket)
|
|
|
|
checkLogin(socket)
|
|
|
|
|
|
|
|
|
|
|
|
callback({
|
|
|
|
callback({
|
|
|
|
ok: true,
|
|
|
|
ok: true,
|
|
|
|
data: await getSettings(type),
|
|
|
|
data: await getSettings("general"),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
callback({
|
|
|
|
|
|
|
|
ok: false,
|
|
|
|
|
|
|
|
msg: e.message,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket.on("setSettings", async (data, callback) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
checkLogin(socket)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await setSettings("general", data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
callback({
|
|
|
|
|
|
|
|
ok: true,
|
|
|
|
|
|
|
|
msg: "Saved"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|