Update jsDoc in nodeController
This commit is contained in:
@@ -7,13 +7,14 @@ const utils = require("../utilities/utils");
|
||||
const { sendHttpRequest, requestOptions } = require("../utilities/httpRequests.js");
|
||||
const { nodeObject } = require("../utilities/recordHelper.js");
|
||||
const { joinServerWrapper } = require("../commands/join");
|
||||
const { leaveServerWrapper } = require("../commands/leave");
|
||||
|
||||
const refreshInterval = process.env.NODE_MONITOR_REFRESH_INTERVAL ?? 1200000;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
* @param {*} req Default express req from router
|
||||
* @param {*} res Defualt express res from router
|
||||
*/
|
||||
exports.listAllNodes = async (req, res) => {
|
||||
getAllNodes((allNodes) => {
|
||||
@@ -23,7 +24,11 @@ exports.listAllNodes = async (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
// Add a new node to the storage
|
||||
/**
|
||||
* Add a new node to the storage
|
||||
* @param {*} req Default express req from router
|
||||
* @param {*} res Defualt express res from router
|
||||
*/
|
||||
exports.newNode = async (req, res) => {
|
||||
if (!req.body.name) return res.status(400).json("No name specified for new node");
|
||||
|
||||
@@ -53,7 +58,11 @@ exports.newNode = async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Get the known info for the node specified
|
||||
/** Get the known info for the node specified
|
||||
*
|
||||
* @param {*} req Default express req from router
|
||||
* @param {*} res Defualt express res from router
|
||||
*/
|
||||
exports.getNodeInfo = async (req, res) => {
|
||||
if (!req.query.id) return res.status(400).json("No id specified");
|
||||
getNodeInfoFromId(req.query.id, (nodeInfo) => {
|
||||
@@ -61,7 +70,11 @@ exports.getNodeInfo = async (req, res) => {
|
||||
})
|
||||
}
|
||||
|
||||
// Updates the information received from the client based on ID
|
||||
/** Updates the information received from the client based on ID
|
||||
*
|
||||
* @param {*} req Default express req from router
|
||||
* @param {*} res Defualt express res from router
|
||||
*/
|
||||
exports.nodeCheckIn = async (req, res) => {
|
||||
if (!req.body.id) return res.status(400).json("No id specified");
|
||||
getNodeInfoFromId(req.body.id, (nodeInfo) => {
|
||||
@@ -126,6 +139,8 @@ exports.nodeCheckIn = async (req, res) => {
|
||||
/**
|
||||
* Request the node to join the specified server/channel and listen to the specified resource
|
||||
*
|
||||
* @param {*} req Default express req from router
|
||||
* @param {*} res Defualt express res from router
|
||||
* @param req.body.clientId The client ID to join discord with (NOT dev portal ID, right click user -> Copy ID)
|
||||
* @param req.body.channelId The Channel ID to join in Discord
|
||||
* @param req.body.presetName The preset name to listen to in Discord
|
||||
@@ -135,6 +150,17 @@ exports.requestNodeJoinServer = async (req, res) => {
|
||||
await joinServerWrapper(req.body.presetName, req.body.channelId, req.body.clientId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} req Default express req from router
|
||||
* @param {*} res Defualt express res from router
|
||||
* @param {*} req.body.clientId The client ID to request to leave the server
|
||||
*/
|
||||
exports.requestNodeLeaveServer = async (req, res) => {
|
||||
if (!req.body.ClientId) return res.status(400).json("Missing client ID in request");
|
||||
await leaveServerWrapper({clientId: req.body.ClientId});
|
||||
}
|
||||
|
||||
/**
|
||||
* The node monitor service, this will periodically check in on the online nodes to make sure they are still online
|
||||
*/
|
||||
@@ -143,6 +169,9 @@ exports.nodeMonitorService = class nodeMonitorService {
|
||||
this.log = new DebugBuilder("server", "nodeMonitorService");
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the node monitor service in the background
|
||||
*/
|
||||
async start(){
|
||||
// Wait for the a portion of the refresh period before checking in with the nodes, so the rest of the bot can start
|
||||
await new Promise(resolve => setTimeout(resolve, refreshInterval/10));
|
||||
@@ -161,6 +190,9 @@ exports.nodeMonitorService = class nodeMonitorService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check in with all online nodes and mark any nodes that are actually offline
|
||||
*/
|
||||
async checkInWithOnlineNodes(){
|
||||
getOnlineNodes((nodes) => {
|
||||
this.log.DEBUG("Online Nodes: ", nodes);
|
||||
|
||||
Reference in New Issue
Block a user