From 73b0f905385f9073ff17eab81f56f09de5d1afc9 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Tue, 12 Mar 2024 17:49:56 +0100 Subject: [PATCH] fixed async docstrings to alsways use Promise<> --- server/auth.js | 4 ++-- server/database.js | 2 +- server/docker.js | 2 +- server/model/group.js | 4 ++-- server/model/maintenance.js | 14 +++++++------- server/model/monitor.js | 4 ++-- server/model/status_page.js | 4 ++-- server/monitor-types/tailscale-ping.js | 2 +- server/notification-providers/aliyun-sms.js | 2 +- server/notification-providers/bark.js | 2 +- server/notification-providers/dingding.js | 2 +- server/notification-providers/nostr.js | 2 +- server/uptime-kuma-server.js | 6 +++--- src/components/TagEditDialog.vue | 4 ++-- src/components/TagsManager.vue | 2 +- src/components/notifications/Telegram.vue | 2 +- src/pages/EditMonitor.vue | 2 +- 17 files changed, 30 insertions(+), 30 deletions(-) diff --git a/server/auth.js b/server/auth.js index 5cf96b6f..597cf3d7 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 4a12746f..cfe14fe7 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 bec0e0b1..ee6051df 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 98ac2a47..bd2c3018 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 c6d7386b..516c0377 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) { @@ -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 0bef3b7d..8f3aef8c 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) { diff --git a/server/model/status_page.js b/server/model/status_page.js index 06fa7a68..23558298 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 0a39544e..5950cc21 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 1718bbfe..28156bdf 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 7fe9a7a9..a248afd8 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 1f2f9b67..7e7a953c 100644 --- a/server/notification-providers/dingding.js +++ b/server/notification-providers/dingding.js @@ -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 9d93678f..453b86d0 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/uptime-kuma-server.js b/server/uptime-kuma-server.js index 2eec9c7c..bcf497b5 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 b77967c7..77fce260 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 37e0ca4e..6b77b1c3 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 40473e93..a072c3ed 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 b6274764..e9f3ac83 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() {