Skip to content

Commit

Permalink
Enforce semicolon, fix format globally
Browse files Browse the repository at this point in the history
  • Loading branch information
louislam committed Apr 13, 2022
1 parent 6f72ca4 commit 649f310
Show file tree
Hide file tree
Showing 50 changed files with 184 additions and 198 deletions.
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
module.exports = {
ignorePatterns: [
"test/*",
"server/modules/apicache/*",
"src/util.js"
],
root: true,
env: {
browser: true,
Expand Down Expand Up @@ -34,7 +39,7 @@ module.exports = {
},
],
quotes: ["warn", "double"],
semi: "warn",
semi: "error",
"vue/html-indent": ["warn", 4], // default: 2
"vue/max-attributes-per-line": "off",
"vue/singleline-html-element-content-newline": "off",
Expand Down
10 changes: 5 additions & 5 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
apps: [{
name: "uptime-kuma",
script: "./server/server.js",
}]
}
apps: [{
name: "uptime-kuma",
script: "./server/server.js",
}]
};
12 changes: 6 additions & 6 deletions extra/beta/update-version.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const pkg = require("../../package.json");
const fs = require("fs");
const child_process = require("child_process");
const childProcess = require("child_process");
const util = require("../../src/util");

util.polyfill();
Expand Down Expand Up @@ -32,23 +32,23 @@ if (! exists) {
function commit(version) {
let msg = "Update to " + version;

let res = child_process.spawnSync("git", ["commit", "-m", msg, "-a"]);
let res = childProcess.spawnSync("git", ["commit", "-m", msg, "-a"]);
let stdout = res.stdout.toString().trim();
console.log(stdout);

if (stdout.includes("no changes added to commit")) {
throw new Error("commit error");
}

res = child_process.spawnSync("git", ["push", "origin", "master"]);
res = childProcess.spawnSync("git", ["push", "origin", "master"]);
console.log(res.stdout.toString().trim());
}

function tag(version) {
let res = child_process.spawnSync("git", ["tag", version]);
let res = childProcess.spawnSync("git", ["tag", version]);
console.log(res.stdout.toString().trim());

res = child_process.spawnSync("git", ["push", "origin", version]);
res = childProcess.spawnSync("git", ["push", "origin", version]);
console.log(res.stdout.toString().trim());
}

Expand All @@ -57,7 +57,7 @@ function tagExists(version) {
throw new Error("invalid version");
}

let res = child_process.spawnSync("git", ["tag", "-l", version]);
let res = childProcess.spawnSync("git", ["tag", "-l", version]);

return res.stdout.toString().trim() === version;
}
Expand Down
18 changes: 9 additions & 9 deletions extra/mark-as-nightly.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ const util = require("../src/util");

util.polyfill();

const oldVersion = pkg.version
const newVersion = oldVersion + "-nightly"
const oldVersion = pkg.version;
const newVersion = oldVersion + "-nightly";

console.log("Old Version: " + oldVersion)
console.log("New Version: " + newVersion)
console.log("Old Version: " + oldVersion);
console.log("New Version: " + newVersion);

if (newVersion) {
// Process package.json
pkg.version = newVersion
pkg.scripts.setup = pkg.scripts.setup.replaceAll(oldVersion, newVersion)
pkg.scripts["build-docker"] = pkg.scripts["build-docker"].replaceAll(oldVersion, newVersion)
fs.writeFileSync("package.json", JSON.stringify(pkg, null, 4) + "\n")
pkg.version = newVersion;
pkg.scripts.setup = pkg.scripts.setup.replaceAll(oldVersion, newVersion);
pkg.scripts["build-docker"] = pkg.scripts["build-docker"].replaceAll(oldVersion, newVersion);
fs.writeFileSync("package.json", JSON.stringify(pkg, null, 4) + "\n");

// Process README.md
if (fs.existsSync("README.md")) {
fs.writeFileSync("README.md", fs.readFileSync("README.md", "utf8").replaceAll(oldVersion, newVersion))
fs.writeFileSync("README.md", fs.readFileSync("README.md", "utf8").replaceAll(oldVersion, newVersion));
}
}
2 changes: 1 addition & 1 deletion extra/simple-dns-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ server.on("request", (request, send, rinfo) => {
ttl: 300,
address: "1.2.3.4"
});
} if (question.type === Packet.TYPE.AAAA) {
} else if (question.type === Packet.TYPE.AAAA) {
response.answers.push({
name: question.name,
type: question.type,
Expand Down
14 changes: 7 additions & 7 deletions server/model/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,18 @@ class Monitor extends BeanModel {
* @returns {Promise<object>}
*/
async updateTlsInfo(checkCertificateResult) {
let tls_info_bean = await R.findOne("monitor_tls_info", "monitor_id = ?", [
let tlsInfoBean = await R.findOne("monitor_tls_info", "monitor_id = ?", [
this.id,
]);

if (tls_info_bean == null) {
tls_info_bean = R.dispense("monitor_tls_info");
tls_info_bean.monitor_id = this.id;
if (tlsInfoBean == null) {
tlsInfoBean = R.dispense("monitor_tls_info");
tlsInfoBean.monitor_id = this.id;
} else {

// Clear sent history if the cert changed.
try {
let oldCertInfo = JSON.parse(tls_info_bean.info_json);
let oldCertInfo = JSON.parse(tlsInfoBean.info_json);

let isValidObjects = oldCertInfo && oldCertInfo.certInfo && checkCertificateResult && checkCertificateResult.certInfo;

Expand All @@ -567,8 +567,8 @@ class Monitor extends BeanModel {

}

tls_info_bean.info_json = JSON.stringify(checkCertificateResult);
await R.store(tls_info_bean);
tlsInfoBean.info_json = JSON.stringify(checkCertificateResult);
await R.store(tlsInfoBean);

return checkCertificateResult;
}
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/apprise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Apprise extends NotificationProvider {
name = "apprise";

async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let s = child_process.spawnSync("apprise", [ "-vv", "-b", msg, notification.appriseURL])
let s = child_process.spawnSync("apprise", [ "-vv", "-b", msg, notification.appriseURL]);

let output = (s.stdout) ? s.stdout.toString() : "ERROR: maybe apprise not found";

Expand All @@ -16,7 +16,7 @@ class Apprise extends NotificationProvider {
return "Sent Successfully";
}

throw new Error(output)
throw new Error(output);
} else {
return "No output from apprise";
}
Expand Down
37 changes: 16 additions & 21 deletions server/notification-providers/bark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,26 @@ class Bark extends NotificationProvider {
name = "Bark";

async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
try {
var barkEndpoint = notification.barkEndpoint;
let barkEndpoint = notification.barkEndpoint;

// check if the endpoint has a "/" suffix, if so, delete it first
if (barkEndpoint.endsWith("/")) {
barkEndpoint = barkEndpoint.substring(0, barkEndpoint.length - 1);
}

if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] == UP) {
let title = "UptimeKuma Monitor Up";
return await this.postNotification(title, msg, barkEndpoint);
}
// check if the endpoint has a "/" suffix, if so, delete it first
if (barkEndpoint.endsWith("/")) {
barkEndpoint = barkEndpoint.substring(0, barkEndpoint.length - 1);
}

if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] == DOWN) {
let title = "UptimeKuma Monitor Down";
return await this.postNotification(title, msg, barkEndpoint);
}
if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] == UP) {
let title = "UptimeKuma Monitor Up";
return await this.postNotification(title, msg, barkEndpoint);
}

if (msg != null) {
let title = "UptimeKuma Message";
return await this.postNotification(title, msg, barkEndpoint);
}
if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] == DOWN) {
let title = "UptimeKuma Monitor Down";
return await this.postNotification(title, msg, barkEndpoint);
}

} catch (error) {
throw error;
if (msg != null) {
let title = "UptimeKuma Message";
return await this.postNotification(title, msg, barkEndpoint);
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/clicksendsms.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ClickSendSMS extends NotificationProvider {
let config = {
headers: {
"Content-Type": "application/json",
"Authorization": "Basic " + Buffer.from(notification.clicksendsmsLogin + ":" + notification.clicksendsmsPassword).toString('base64'),
"Authorization": "Basic " + Buffer.from(notification.clicksendsmsLogin + ":" + notification.clicksendsmsPassword).toString("base64"),
"Accept": "text/json",
}
};
Expand Down
14 changes: 7 additions & 7 deletions server/notification-providers/discord.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Discord extends NotificationProvider {
let discordtestdata = {
username: discordDisplayName,
content: msg,
}
await axios.post(notification.discordWebhookUrl, discordtestdata)
};
await axios.post(notification.discordWebhookUrl, discordtestdata);
return okMsg;
}

Expand Down Expand Up @@ -61,13 +61,13 @@ class Discord extends NotificationProvider {
},
],
}],
}
};

if (notification.discordPrefixMessage) {
discorddowndata.content = notification.discordPrefixMessage;
}

await axios.post(notification.discordWebhookUrl, discorddowndata)
await axios.post(notification.discordWebhookUrl, discorddowndata);
return okMsg;

} else if (heartbeatJSON["status"] == UP) {
Expand Down Expand Up @@ -96,17 +96,17 @@ class Discord extends NotificationProvider {
},
],
}],
}
};

if (notification.discordPrefixMessage) {
discordupdata.content = notification.discordPrefixMessage;
}

await axios.post(notification.discordWebhookUrl, discordupdata)
await axios.post(notification.discordWebhookUrl, discordupdata);
return okMsg;
}
} catch (error) {
this.throwGeneralAxiosError(error)
this.throwGeneralAxiosError(error);
}
}

Expand Down
6 changes: 3 additions & 3 deletions server/notification-providers/google-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class GoogleChat extends NotificationProvider {
try {
// Google Chat message formatting: https://developers.google.com/chat/api/guides/message-formats/basic

let textMsg = ''
let textMsg = "";
if (heartbeatJSON && heartbeatJSON.status === UP) {
textMsg = `✅ Application is back online\n`;
textMsg = "✅ Application is back online\n";
} else if (heartbeatJSON && heartbeatJSON.status === DOWN) {
textMsg = `🔴 Application went down\n`;
textMsg = "🔴 Application went down\n";
}

if (monitorJSON && monitorJSON.name) {
Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/gotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Gotify extends NotificationProvider {
"message": msg,
"priority": notification.gotifyPriority || 8,
"title": "Uptime-Kuma",
})
});

return okMsg;

Expand Down
14 changes: 7 additions & 7 deletions server/notification-providers/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class Line extends NotificationProvider {
"text": "Test Successful!"
}
]
}
await axios.post(lineAPIUrl, testMessage, config)
};
await axios.post(lineAPIUrl, testMessage, config);
} else if (heartbeatJSON["status"] == DOWN) {
let downMessage = {
"to": notification.lineUserID,
Expand All @@ -36,8 +36,8 @@ class Line extends NotificationProvider {
"text": "UptimeKuma Alert: [🔴 Down]\n" + "Name: " + monitorJSON["name"] + " \n" + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"]
}
]
}
await axios.post(lineAPIUrl, downMessage, config)
};
await axios.post(lineAPIUrl, downMessage, config);
} else if (heartbeatJSON["status"] == UP) {
let upMessage = {
"to": notification.lineUserID,
Expand All @@ -47,12 +47,12 @@ class Line extends NotificationProvider {
"text": "UptimeKuma Alert: [✅ Up]\n" + "Name: " + monitorJSON["name"] + " \n" + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"]
}
]
}
await axios.post(lineAPIUrl, upMessage, config)
};
await axios.post(lineAPIUrl, upMessage, config);
}
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error)
this.throwGeneralAxiosError(error);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions server/notification-providers/lunasea.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,38 @@ class LunaSea extends NotificationProvider {

async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
let lunaseadevice = "https://notify.lunasea.app/v1/custom/device/" + notification.lunaseaDevice
let lunaseadevice = "https://notify.lunasea.app/v1/custom/device/" + notification.lunaseaDevice;

try {
if (heartbeatJSON == null) {
let testdata = {
"title": "Uptime Kuma Alert",
"body": "Testing Successful.",
}
await axios.post(lunaseadevice, testdata)
};
await axios.post(lunaseadevice, testdata);
return okMsg;
}

if (heartbeatJSON["status"] == DOWN) {
let downdata = {
"title": "UptimeKuma Alert: " + monitorJSON["name"],
"body": "[🔴 Down] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"],
}
await axios.post(lunaseadevice, downdata)
};
await axios.post(lunaseadevice, downdata);
return okMsg;
}

if (heartbeatJSON["status"] == UP) {
let updata = {
"title": "UptimeKuma Alert: " + monitorJSON["name"],
"body": "[✅ Up] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"],
}
await axios.post(lunaseadevice, updata)
};
await axios.post(lunaseadevice, updata);
return okMsg;
}

} catch (error) {
this.throwGeneralAxiosError(error)
this.throwGeneralAxiosError(error);
}

}
Expand Down
4 changes: 2 additions & 2 deletions server/notification-providers/notification-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class NotificationProvider {
if (typeof error.response.data === "string") {
msg += error.response.data;
} else {
msg += JSON.stringify(error.response.data)
msg += JSON.stringify(error.response.data);
}
}

throw new Error(msg)
throw new Error(msg);
}
}

Expand Down
Loading

0 comments on commit 649f310

Please sign in to comment.