Merge code manually since some code moved to another file

This commit is contained in:
Louis Lam 2022-04-19 16:46:45 +08:00
parent 29d2d95c71
commit 200fdfb808
2 changed files with 18 additions and 5 deletions

View File

@ -1541,6 +1541,11 @@ async function afterLogin(socket, user) {
} }
} }
/**
* Connect to the database and patch it if necessary.
*
* Generated by Trelent
*/
async function initDatabase(testMode = false) { async function initDatabase(testMode = false) {
if (! fs.existsSync(Database.path)) { if (! fs.existsSync(Database.path)) {
log.info("server", "Copying Database"); log.info("server", "Copying Database");

View File

@ -4,6 +4,7 @@ const fs = require("fs");
const http = require("http"); const http = require("http");
const { Server } = require("socket.io"); const { Server } = require("socket.io");
const { R } = require("redbean-node"); const { R } = require("redbean-node");
const { log } = require("../src/util");
/** /**
* `module.exports` (alias: `server`) should be inside this class, in order to avoid circular dependency issue. * `module.exports` (alias: `server`) should be inside this class, in order to avoid circular dependency issue.
@ -36,20 +37,20 @@ class UptimeKumaServer {
constructor(args) { constructor(args) {
// SSL // SSL
const sslKey = process.env.UPTIME_KUMA_SSL_KEY || process.env.SSL_KEY || args["ssl-key"] || undefined; const sslKey = args["ssl-key"] || process.env.UPTIME_KUMA_SSL_KEY || process.env.SSL_KEY || undefined;
const sslCert = process.env.UPTIME_KUMA_SSL_CERT || process.env.SSL_CERT || args["ssl-cert"] || undefined; const sslCert = args["ssl-cert"] || process.env.UPTIME_KUMA_SSL_CERT || process.env.SSL_CERT || undefined;
console.log("Creating express and socket.io instance"); log.info("server", "Creating express and socket.io instance");
this.app = express(); this.app = express();
if (sslKey && sslCert) { if (sslKey && sslCert) {
console.log("Server Type: HTTPS"); log.info("server", "Server Type: HTTPS");
this.httpServer = https.createServer({ this.httpServer = https.createServer({
key: fs.readFileSync(sslKey), key: fs.readFileSync(sslKey),
cert: fs.readFileSync(sslCert) cert: fs.readFileSync(sslCert)
}, this.app); }, this.app);
} else { } else {
console.log("Server Type: HTTP"); log.info("server", "Server Type: HTTP");
this.httpServer = http.createServer(this.app); this.httpServer = http.createServer(this.app);
} }
@ -62,6 +63,13 @@ class UptimeKumaServer {
return list; return list;
} }
/**
* Get a list of monitors for the given user.
* @param {string} userID - The ID of the user to get monitors for.
* @returns {Promise<Object>} A promise that resolves to an object with monitor IDs as keys and monitor objects as values.
*
* Generated by Trelent
*/
async getMonitorJSONList(userID) { async getMonitorJSONList(userID) {
let result = {}; let result = {};