fixed async docstrings to alsways use Promise<>

pull/4574/head
Frank Elsinga 2 months ago
parent bf411c4a13
commit 73b0f90538

@ -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<void>}
*/
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<void>}
*/
exports.apiAuth = async function (req, res, next) {
if (!await Settings.get("disableAuth")) {

@ -378,7 +378,7 @@ class Database {
/**
* Patch the database
* @returns {void}
* @returns {Promise<void>}
*/
static async patch() {
// Still need to keep this for old versions of Uptime Kuma

@ -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<number>} Total amount of containers on the host
*/
static async testDockerHost(dockerHost) {
const options = {

@ -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>} 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<Bean[]>} List of monitors
*/
async getMonitorList() {
return R.convertToBeans("monitor", await R.getAll(`

@ -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>} 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>} 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<Bean>} 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<boolean>} 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<string>} 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<string>} 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<string>} Current status
*/
async getStatus() {
if (!this.active) {

@ -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>} 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>} Object ready to parse
*/
async toJSON(includeSensitiveData = true) {

@ -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<void>}
*/
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<string>} the rendered html
*/
static async renderHTML(indexHTML, statusPage) {
const $ = cheerio.load(indexHTML);

@ -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<void>}
* @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 {

@ -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<boolean>} True if successful else false
*/
async sendSms(notification, msgbody) {
let params = {

@ -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<string>} Success message
*/
async postNotification(notification, title, subtitle, endpoint) {
let result;

@ -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<boolean>} True if successful else false
*/
async sendToDingDing(notification, params) {
let timestamp = Date.now();

@ -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<nip19.DecodeResult[]>} Public keys
*/
async getPublicKeys(recipients) {
const recipientsList = recipients.split("\n");

@ -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<object>} 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<object>} 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<object>} Maintenance list
*/
async sendMaintenanceListByUserID(userID) {
let list = await this.getMaintenanceJSONList(userID);

@ -288,7 +288,7 @@ export default {
/**
* Submit tag and monitorTag changes to server
* @returns {void}
* @returns {Promise<void>}
*/
async submit() {
this.processing = true;
@ -348,7 +348,7 @@ export default {
/**
* Delete the editing tag from server
* @returns {void}
* @returns {Promise<void>}
*/
async deleteTag() {
this.processing = true;

@ -384,7 +384,7 @@ export default {
/**
* Submit the form data
* @param {number} monitorId ID of monitor this change affects
* @returns {void}
* @returns {Promise<void>}
*/
async submit(monitorId) {
console.log(`Submitting tag changes for monitor ${monitorId}...`);

@ -85,7 +85,7 @@ export default {
/**
* Get the telegram chat ID
* @returns {void}
* @returns {Promise<void>}
* @throws The chat ID could not be found
*/
async autoGetTelegramChatID() {

@ -1470,7 +1470,7 @@ message HealthCheckResponse {
/**
* Submit the form data for processing
* @returns {void}
* @returns {Promise<void>}
*/
async submit() {

Loading…
Cancel
Save