mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-26 06:04:13 -08:00
Add JSDoc to server/socket-handlers/*
Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
This commit is contained in:
parent
3d04befc1f
commit
068b920553
|
@ -6,15 +6,28 @@ const io = UptimeKumaServer.getInstance().io;
|
||||||
const prefix = "cloudflared_";
|
const prefix = "cloudflared_";
|
||||||
const cloudflared = new CloudflaredTunnel();
|
const cloudflared = new CloudflaredTunnel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change running state
|
||||||
|
* @param {string} running Is it running?
|
||||||
|
* @param {string} message Message to pass
|
||||||
|
*/
|
||||||
cloudflared.change = (running, message) => {
|
cloudflared.change = (running, message) => {
|
||||||
io.to("cloudflared").emit(prefix + "running", running);
|
io.to("cloudflared").emit(prefix + "running", running);
|
||||||
io.to("cloudflared").emit(prefix + "message", message);
|
io.to("cloudflared").emit(prefix + "message", message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit an error message
|
||||||
|
* @param {string} errorMessage
|
||||||
|
*/
|
||||||
cloudflared.error = (errorMessage) => {
|
cloudflared.error = (errorMessage) => {
|
||||||
io.to("cloudflared").emit(prefix + "errorMessage", errorMessage);
|
io.to("cloudflared").emit(prefix + "errorMessage", errorMessage);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for cloudflared
|
||||||
|
* @param {Socket} socket Socket.io instance
|
||||||
|
*/
|
||||||
module.exports.cloudflaredSocketHandler = (socket) => {
|
module.exports.cloudflaredSocketHandler = (socket) => {
|
||||||
|
|
||||||
socket.on(prefix + "join", async () => {
|
socket.on(prefix + "join", async () => {
|
||||||
|
@ -69,6 +82,10 @@ module.exports.cloudflaredSocketHandler = (socket) => {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatically start cloudflared
|
||||||
|
* @param {string} token Cloudflared tunnel token
|
||||||
|
*/
|
||||||
module.exports.autoStart = async (token) => {
|
module.exports.autoStart = async (token) => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
token = await setting("cloudflaredTunnelToken");
|
token = await setting("cloudflaredTunnelToken");
|
||||||
|
@ -85,6 +102,7 @@ module.exports.autoStart = async (token) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Stop cloudflared */
|
||||||
module.exports.stop = async () => {
|
module.exports.stop = async () => {
|
||||||
console.log("Stop cloudflared");
|
console.log("Stop cloudflared");
|
||||||
if (cloudflared) {
|
if (cloudflared) {
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
const { checkLogin } = require("../util-server");
|
const { checkLogin } = require("../util-server");
|
||||||
const Database = require("../database");
|
const Database = require("../database");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handlers for database
|
||||||
|
* @param {Socket} socket Socket.io instance
|
||||||
|
*/
|
||||||
module.exports = (socket) => {
|
module.exports = (socket) => {
|
||||||
|
|
||||||
// Post or edit incident
|
// Post or edit incident
|
||||||
|
|
|
@ -4,6 +4,10 @@ const { sendProxyList } = require("../client");
|
||||||
const { UptimeKumaServer } = require("../uptime-kuma-server");
|
const { UptimeKumaServer } = require("../uptime-kuma-server");
|
||||||
const server = UptimeKumaServer.getInstance();
|
const server = UptimeKumaServer.getInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handlers for proxy
|
||||||
|
* @param {Socket} socket Socket.io instance
|
||||||
|
*/
|
||||||
module.exports.proxySocketHandler = (socket) => {
|
module.exports.proxySocketHandler = (socket) => {
|
||||||
socket.on("addProxy", async (proxy, proxyID, callback) => {
|
socket.on("addProxy", async (proxy, proxyID, callback) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -8,6 +8,10 @@ const apicache = require("../modules/apicache");
|
||||||
const StatusPage = require("../model/status_page");
|
const StatusPage = require("../model/status_page");
|
||||||
const { UptimeKumaServer } = require("../uptime-kuma-server");
|
const { UptimeKumaServer } = require("../uptime-kuma-server");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Socket handlers for status page
|
||||||
|
* @param {Socket} socket Socket.io instance to add listeners on
|
||||||
|
*/
|
||||||
module.exports.statusPageSocketHandler = (socket) => {
|
module.exports.statusPageSocketHandler = (socket) => {
|
||||||
|
|
||||||
// Post or edit incident
|
// Post or edit incident
|
||||||
|
@ -338,6 +342,7 @@ module.exports.statusPageSocketHandler = (socket) => {
|
||||||
/**
|
/**
|
||||||
* Check slug a-z, 0-9, - only
|
* Check slug a-z, 0-9, - only
|
||||||
* Regex from: https://stackoverflow.com/questions/22454258/js-regex-string-validation-for-slug
|
* Regex from: https://stackoverflow.com/questions/22454258/js-regex-string-validation-for-slug
|
||||||
|
* @param {string} slug Slug to test
|
||||||
*/
|
*/
|
||||||
function checkSlug(slug) {
|
function checkSlug(slug) {
|
||||||
if (typeof slug !== "string") {
|
if (typeof slug !== "string") {
|
||||||
|
|
Loading…
Reference in a new issue