Files
LupiNex-Connect/servers/dashboard/functions.js
T
2026-06-29 20:14:06 +02:00

49 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
! /servers/Dashboard/functions.js Central Dashboard Server Functions
? This modules exports the functionality for the express dashboard server
*/
// % core variables
const ip = process.env.INTERNAL_HOST_IP;
const port = process.env.INTERNAL_DASHBOARD_PORT;
// $ server start function
async function boot(server) {
// ~ start express server
server.listen(port, ip, () => {
console.info(`Express server is now running on http://${ip}:${port}`)
});
// ~ return running express server reference
return server;
};
// $ server shutdown function
async function shutdown(server) {
// ~ shutdown running express server
server.close();
// ~ return express server reference
return server;
};
// $ server restart function
async function restart(server) {
// ~ shutdown the running express server
await shutdown(server);
// ~ restart the express server
await boot(server);
// ~ return the server reference
return server;
};
// $ server status function
async function status(server) {
// ~ get and return server listening status
return server.listening ? 'online' : 'offline';
};
// § export server functions module
module.exports = { boot, shutdown, restart, status };