|
|
|
@ -1,25 +1,45 @@
|
|
|
|
|
console.log("Welcome to Uptime Kuma ")
|
|
|
|
|
console.log("Importing libraries")
|
|
|
|
|
const express = require("express");
|
|
|
|
|
console.log("Welcome to Uptime Kuma")
|
|
|
|
|
|
|
|
|
|
const { sleep, debug } = require("../src/util");
|
|
|
|
|
|
|
|
|
|
console.log("Importing Node libraries")
|
|
|
|
|
const fs = require("fs");
|
|
|
|
|
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");
|
|
|
|
|
debug("Importing dayjs");
|
|
|
|
|
const dayjs = require("dayjs");
|
|
|
|
|
debug("Importing redbean-node");
|
|
|
|
|
const { R } = require("redbean-node");
|
|
|
|
|
debug("Importing jsonwebtoken");
|
|
|
|
|
const jwt = require("jsonwebtoken");
|
|
|
|
|
const Monitor = require("./model/monitor");
|
|
|
|
|
const fs = require("fs");
|
|
|
|
|
const { getSettings } = require("./util-server");
|
|
|
|
|
const { Notification } = require("./notification")
|
|
|
|
|
debug("Importing http-graceful-shutdown");
|
|
|
|
|
const gracefulShutdown = require("http-graceful-shutdown");
|
|
|
|
|
const Database = require("./database");
|
|
|
|
|
const { sleep } = require("../src/util");
|
|
|
|
|
const args = require("args-parser")(process.argv);
|
|
|
|
|
debug("Importing 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 { login } = require("./auth");
|
|
|
|
|
const passwordHash = require("./password-hash");
|
|
|
|
|
|
|
|
|
|
const args = require("args-parser")(process.argv);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
checkLogin(socket)
|
|
|
|
|
|
|
|
|
|
callback({
|
|
|
|
|
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) {
|
|
|
|
|