diff --git a/server/auth.js b/server/auth.js index 5cf96b6ff..597cf3d75 100644 --- a/server/auth.js +++ b/server/auth.js @@ -130,7 +130,7 @@ function userAuthorizer(username, password, callback) { * @param {express.Request} req Express request object * @param {express.Response} res Express response object * @param {express.NextFunction} next Next handler in chain - * @returns {void} + * @returns {Promise} */ exports.basicAuth = async function (req, res, next) { const middleware = basicAuth({ @@ -153,7 +153,7 @@ exports.basicAuth = async function (req, res, next) { * @param {express.Request} req Express request object * @param {express.Response} res Express response object * @param {express.NextFunction} next Next handler in chain - * @returns {void} + * @returns {Promise} */ exports.apiAuth = async function (req, res, next) { if (!await Settings.get("disableAuth")) { diff --git a/server/database.js b/server/database.js index 4a12746f5..cfe14fe71 100644 --- a/server/database.js +++ b/server/database.js @@ -378,7 +378,7 @@ class Database { /** * Patch the database - * @returns {void} + * @returns {Promise} */ static async patch() { // Still need to keep this for old versions of Uptime Kuma diff --git a/server/docker.js b/server/docker.js index bec0e0b12..ee6051dfa 100644 --- a/server/docker.js +++ b/server/docker.js @@ -65,7 +65,7 @@ class DockerHost { /** * Fetches the amount of containers on the Docker host * @param {object} dockerHost Docker host to check for - * @returns {number} Total amount of containers on the host + * @returns {Promise} Total amount of containers on the host */ static async testDockerHost(dockerHost) { const options = { diff --git a/server/model/group.js b/server/model/group.js index 98ac2a474..bd2c30189 100644 --- a/server/model/group.js +++ b/server/model/group.js @@ -9,7 +9,7 @@ class Group extends BeanModel { * @param {boolean} showTags Should the JSON include monitor tags * @param {boolean} certExpiry Should JSON include info about * certificate expiry? - * @returns {object} Object ready to parse + * @returns {Promise} Object ready to parse */ async toPublicJSON(showTags = false, certExpiry = false) { let monitorBeanList = await this.getMonitorList(); @@ -29,7 +29,7 @@ class Group extends BeanModel { /** * Get all monitors - * @returns {Bean[]} List of monitors + * @returns {Promise} List of monitors */ async getMonitorList() { return R.convertToBeans("monitor", await R.getAll(` diff --git a/server/model/maintenance.js b/server/model/maintenance.js index fb51060e3..516c03777 100644 --- a/server/model/maintenance.js +++ b/server/model/maintenance.js @@ -11,7 +11,7 @@ class Maintenance extends BeanModel { /** * Return an object that ready to parse to JSON for public * Only show necessary data to public - * @returns {object} Object ready to parse + * @returns {Promise} Object ready to parse */ async toPublicJSON() { @@ -98,7 +98,7 @@ class Maintenance extends BeanModel { /** * Return an object that ready to parse to JSON * @param {string} timezone If not specified, the timeRange will be in UTC - * @returns {object} Object ready to parse + * @returns {Promise} Object ready to parse */ async toJSON(timezone = null) { return this.toPublicJSON(timezone); @@ -143,7 +143,7 @@ class Maintenance extends BeanModel { * Convert data from socket to bean * @param {Bean} bean Bean to fill in * @param {object} obj Data to fill bean with - * @returns {Bean} Filled bean + * @returns {Promise} Filled bean */ static async jsonToBean(bean, obj) { if (obj.id) { @@ -189,9 +189,9 @@ class Maintenance extends BeanModel { /** * Throw error if cron is invalid * @param {string|Date} cron Pattern or date - * @returns {Promise} + * @returns {void} */ - static async validateCron(cron) { + static validateCron(cron) { let job = new Cron(cron, () => {}); job.stop(); } @@ -324,7 +324,7 @@ class Maintenance extends BeanModel { /** * Is this maintenance currently active - * @returns {boolean} The maintenance is active? + * @returns {Promise} The maintenance is active? */ async isUnderMaintenance() { return (await this.getStatus()) === "under-maintenance"; @@ -332,7 +332,7 @@ class Maintenance extends BeanModel { /** * Get the timezone of the maintenance - * @returns {string} timezone + * @returns {Promise} timezone */ async getTimezone() { if (!this.timezone || this.timezone === "SAME_AS_SERVER") { @@ -343,7 +343,7 @@ class Maintenance extends BeanModel { /** * Get offset for timezone - * @returns {string} offset + * @returns {Promise} offset */ async getTimezoneOffset() { return dayjs.tz(dayjs(), await this.getTimezone()).format("Z"); @@ -351,7 +351,7 @@ class Maintenance extends BeanModel { /** * Get the current status of the maintenance - * @returns {string} Current status + * @returns {Promise} Current status */ async getStatus() { if (!this.active) { diff --git a/server/model/monitor.js b/server/model/monitor.js index 503670734..1667b83a8 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -43,7 +43,7 @@ class Monitor extends BeanModel { * @param {boolean} showTags Include tags in JSON * @param {boolean} certExpiry Include certificate expiry info in * JSON - * @returns {object} Object ready to parse + * @returns {Promise} Object ready to parse */ async toPublicJSON(showTags = false, certExpiry = false) { let obj = { @@ -74,7 +74,7 @@ class Monitor extends BeanModel { * Return an object that ready to parse to JSON * @param {boolean} includeSensitiveData Include sensitive data in * JSON - * @returns {object} Object ready to parse + * @returns {Promise} Object ready to parse */ async toJSON(includeSensitiveData = true) { @@ -947,7 +947,7 @@ class Monitor extends BeanModel { log.debug("monitor", `[${this.name}] apicache clear`); apicache.clear(); - UptimeKumaServer.getInstance().sendMaintenanceListByUserID(this.user_id); + await UptimeKumaServer.getInstance().sendMaintenanceListByUserID(this.user_id); } else { bean.important = false; @@ -1377,7 +1377,7 @@ class Monitor extends BeanModel { let notifyDays = await setting("tlsExpiryNotifyDays"); if (notifyDays == null || !Array.isArray(notifyDays)) { // Reset Default - setSetting("tlsExpiryNotifyDays", [ 7, 14, 21 ], "general"); + await setSetting("tlsExpiryNotifyDays", [ 7, 14, 21 ], "general"); notifyDays = [ 7, 14, 21 ]; } diff --git a/server/model/status_page.js b/server/model/status_page.js index 06fa7a685..235582981 100644 --- a/server/model/status_page.js +++ b/server/model/status_page.js @@ -18,7 +18,7 @@ class StatusPage extends BeanModel { * @param {Response} response Response object * @param {string} indexHTML HTML to render * @param {string} slug Status page slug - * @returns {void} + * @returns {Promise} */ static async handleStatusPageResponse(response, indexHTML, slug) { // Handle url with trailing slash (http://localhost:3001/status/) @@ -42,7 +42,7 @@ class StatusPage extends BeanModel { * SSR for status pages * @param {string} indexHTML HTML page to render * @param {StatusPage} statusPage Status page populate HTML with - * @returns {void} + * @returns {Promise} the rendered html */ static async renderHTML(indexHTML, statusPage) { const $ = cheerio.load(indexHTML); diff --git a/server/monitor-types/tailscale-ping.js b/server/monitor-types/tailscale-ping.js index 0a39544e8..5950cc21c 100644 --- a/server/monitor-types/tailscale-ping.js +++ b/server/monitor-types/tailscale-ping.js @@ -16,7 +16,7 @@ class TailscalePing extends MonitorType { * @param {object} monitor The monitor object associated with the check. * @param {object} heartbeat The heartbeat object to update. * @returns {Promise} - * @throws Will throw an error if checking Tailscale ping encounters any error + * @throws Error if checking Tailscale ping encounters any error */ async check(monitor, heartbeat) { try { diff --git a/server/notification-providers/aliyun-sms.js b/server/notification-providers/aliyun-sms.js index b895f70a1..ff38bd0d9 100644 --- a/server/notification-providers/aliyun-sms.js +++ b/server/notification-providers/aliyun-sms.js @@ -44,7 +44,7 @@ class AliyunSMS extends NotificationProvider { * Send the SMS notification * @param {BeanModel} notification Notification details * @param {string} msgbody Message template - * @returns {boolean} True if successful else false + * @returns {Promise} True if successful else false */ async sendSms(notification, msgbody) { let params = { diff --git a/server/notification-providers/bark.js b/server/notification-providers/bark.js index 4d6c0ae04..0907d5f10 100644 --- a/server/notification-providers/bark.js +++ b/server/notification-providers/bark.js @@ -92,7 +92,7 @@ class Bark extends NotificationProvider { * @param {string} title Message title * @param {string} subtitle Message * @param {string} endpoint Endpoint to send request to - * @returns {string} Success message + * @returns {Promise} Success message */ async postNotification(notification, title, subtitle, endpoint) { let result; diff --git a/server/notification-providers/dingding.js b/server/notification-providers/dingding.js index 3aa819229..5e7f030b5 100644 --- a/server/notification-providers/dingding.js +++ b/server/notification-providers/dingding.js @@ -21,7 +21,7 @@ class DingDing extends NotificationProvider { text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`, } }; - if (this.sendToDingDing(notification, params)) { + if (await this.sendToDingDing(notification, params)) { return okMsg; } } else { @@ -31,7 +31,7 @@ class DingDing extends NotificationProvider { content: msg } }; - if (this.sendToDingDing(notification, params)) { + if (await this.sendToDingDing(notification, params)) { return okMsg; } } @@ -44,7 +44,7 @@ class DingDing extends NotificationProvider { * Send message to DingDing * @param {BeanModel} notification Notification to send * @param {object} params Parameters of message - * @returns {boolean} True if successful else false + * @returns {Promise} True if successful else false */ async sendToDingDing(notification, params) { let timestamp = Date.now(); diff --git a/server/notification-providers/nostr.js b/server/notification-providers/nostr.js index 9d93678f2..453b86d0a 100644 --- a/server/notification-providers/nostr.js +++ b/server/notification-providers/nostr.js @@ -107,7 +107,7 @@ class Nostr extends NotificationProvider { /** * Get public keys for recipients * @param {string} recipients Newline delimited list of recipients - * @returns {nip19.DecodeResult[]} Public keys + * @returns {Promise} Public keys */ async getPublicKeys(recipients) { const recipientsList = recipients.split("\n"); diff --git a/server/server.js b/server/server.js index b950dc0d3..457324716 100644 --- a/server/server.js +++ b/server/server.js @@ -294,7 +294,7 @@ let needSetup = false; log.debug("server", "Adding socket handler"); io.on("connection", async (socket) => { - sendInfo(socket, true); + await sendInfo(socket, true); if (needSetup) { log.info("server", "Redirect to setup page"); @@ -326,7 +326,7 @@ let needSetup = false; } log.debug("auth", "afterLogin"); - afterLogin(socket, user); + await afterLogin(socket, user); log.debug("auth", "afterLogin ok"); log.info("auth", `Successfully logged in user ${decoded.username}. IP=${clientIP}`); @@ -382,7 +382,7 @@ let needSetup = false; if (user) { if (user.twofa_status === 0) { - afterLogin(socket, user); + await afterLogin(socket, user); log.info("auth", `Successfully logged in user ${data.username}. IP=${clientIP}`); @@ -405,7 +405,7 @@ let needSetup = false; let verify = notp.totp.verify(data.token, user.twofa_secret, twoFAVerifyOptions); if (user.twofa_last_token !== data.token && verify) { - afterLogin(socket, user); + await afterLogin(socket, user); await R.exec("UPDATE `user` SET twofa_last_token = ? WHERE id = ? ", [ data.token, @@ -1351,8 +1351,8 @@ let needSetup = false; msgi18n: true, }); - sendInfo(socket); - server.sendMaintenanceList(socket); + await sendInfo(socket); + await server.sendMaintenanceList(socket); } catch (e) { callback({ @@ -1532,7 +1532,7 @@ let needSetup = false; log.debug("auth", "check auto login"); if (await setting("disableAuth")) { log.info("auth", "Disabled Auth: auto login to admin"); - afterLogin(socket, await R.findOne("user")); + await afterLogin(socket, await R.findOne("user")); socket.emit("autoLogin"); } else { log.debug("auth", "need auth"); @@ -1548,7 +1548,7 @@ let needSetup = false; process.exit(1); }); - server.start(); + await server.start(); server.httpServer.listen(port, hostname, () => { if (hostname) { @@ -1619,13 +1619,13 @@ async function afterLogin(socket, user) { socket.join(user.id); let monitorList = await server.sendMonitorList(socket); - sendInfo(socket); - server.sendMaintenanceList(socket); - sendNotificationList(socket); - sendProxyList(socket); - sendDockerHostList(socket); - sendAPIKeyList(socket); - sendRemoteBrowserList(socket); + await sendInfo(socket); + await server.sendMaintenanceList(socket); + await sendNotificationList(socket); + await sendProxyList(socket); + await sendDockerHostList(socket); + await sendAPIKeyList(socket); + await sendRemoteBrowserList(socket); await sleep(500); diff --git a/server/socket-handlers/database-socket-handler.js b/server/socket-handlers/database-socket-handler.js index 8441520aa..bcf34c906 100644 --- a/server/socket-handlers/database-socket-handler.js +++ b/server/socket-handlers/database-socket-handler.js @@ -27,7 +27,7 @@ module.exports = (socket) => { socket.on("shrinkDatabase", async (callback) => { try { checkLogin(socket); - Database.shrink(); + await Database.shrink(); callback({ ok: true, }); diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index 2eec9c7c1..bcf497b58 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -195,7 +195,7 @@ class UptimeKumaServer { /** * Send list of monitors to client * @param {Socket} socket Socket to send list on - * @returns {object} List of monitors + * @returns {Promise} List of monitors */ async sendMonitorList(socket) { let list = await this.getMonitorJSONList(socket.userID); @@ -227,7 +227,7 @@ class UptimeKumaServer { /** * Send maintenance list to client * @param {Socket} socket Socket.io instance to send to - * @returns {object} Maintenance list + * @returns {Promise} Maintenance list */ async sendMaintenanceList(socket) { return await this.sendMaintenanceListByUserID(socket.userID); @@ -236,7 +236,7 @@ class UptimeKumaServer { /** * Send list of maintenances to user * @param {number} userID User to send list to - * @returns {object} Maintenance list + * @returns {Promise} Maintenance list */ async sendMaintenanceListByUserID(userID) { let list = await this.getMaintenanceJSONList(userID); diff --git a/src/components/TagEditDialog.vue b/src/components/TagEditDialog.vue index b77967c77..77fce2609 100644 --- a/src/components/TagEditDialog.vue +++ b/src/components/TagEditDialog.vue @@ -288,7 +288,7 @@ export default { /** * Submit tag and monitorTag changes to server - * @returns {void} + * @returns {Promise} */ async submit() { this.processing = true; @@ -348,7 +348,7 @@ export default { /** * Delete the editing tag from server - * @returns {void} + * @returns {Promise} */ async deleteTag() { this.processing = true; diff --git a/src/components/TagsManager.vue b/src/components/TagsManager.vue index 37e0ca4ef..6b77b1c39 100644 --- a/src/components/TagsManager.vue +++ b/src/components/TagsManager.vue @@ -384,7 +384,7 @@ export default { /** * Submit the form data * @param {number} monitorId ID of monitor this change affects - * @returns {void} + * @returns {Promise} */ async submit(monitorId) { console.log(`Submitting tag changes for monitor ${monitorId}...`); diff --git a/src/components/notifications/Telegram.vue b/src/components/notifications/Telegram.vue index 40473e93d..a072c3ed3 100644 --- a/src/components/notifications/Telegram.vue +++ b/src/components/notifications/Telegram.vue @@ -85,7 +85,7 @@ export default { /** * Get the telegram chat ID - * @returns {void} + * @returns {Promise} * @throws The chat ID could not be found */ async autoGetTelegramChatID() { diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 72cb181e7..e9f3ac832 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -1470,7 +1470,7 @@ message HealthCheckResponse { /** * Submit the form data for processing - * @returns {void} + * @returns {Promise} */ async submit() { @@ -1535,7 +1535,7 @@ message HealthCheckResponse { // Start the new parent monitor after edit is done if (createdNewParent) { - this.startParentGroupMonitor(); + await this.startParentGroupMonitor(); } this.processing = false; this.$root.getMonitorList();