move userMonitorList out of server.js

This commit is contained in:
LouisLam 2021-09-08 16:27:37 +08:00
parent 230a9bfaf9
commit a7cf14c663
4 changed files with 9 additions and 8 deletions

View File

@ -4,6 +4,7 @@
const { TimeLogger } = require("../src/util");
const { R } = require("redbean-node");
const { io } = require("./server");
const { userMonitorList } = require("./user-monitor-list");
async function sendNotificationList(socket) {
const timeLogger = new TimeLogger();

View File

@ -11,6 +11,7 @@ const { tcping, ping, dnsResolve, checkCertificate, checkStatusCode, getTotalCli
const { R } = require("redbean-node");
const { BeanModel } = require("redbean-node/dist/bean-model");
const { Notification } = require("../notification")
const { userMonitorList } = require("../user-monitor-list");
const version = require("../../package.json").version;
/**

View File

@ -27,7 +27,7 @@ debug("Importing Monitor");
const Monitor = require("./model/monitor");
debug("Importing Settings");
const { getSettings, setSettings, setting, initJWTSecret } = require("./util-server");
const UserMonitorList = require("./user-monitor-list");
const { userMonitorList } = require("./user-monitor-list");
debug("Importing Notification");
const { Notification } = require("./notification");
@ -105,11 +105,6 @@ let totalClient = 0;
*/
let jwtSecret = null;
/**
* Main monitor list, filled by startMonitors()
*/
let userMonitorList = new UserMonitorList();
/**
* Show Setup Page
* @type {boolean}

View File

@ -1,5 +1,7 @@
/**
* Main monitor list
*/
class UserMonitorList {
list = {};
add(userID, monitor) {
@ -46,4 +48,6 @@ class UserMonitorList {
}
module.exports = UserMonitorList;
module.exports = {
userMonitorList: new UserMonitorList(),
};