Completed basic functionality development

This commit is contained in:
Pax1601
2024-01-26 17:31:36 +01:00
parent 613aed2d2b
commit f2161da162
21 changed files with 626 additions and 1139 deletions

View File

@@ -4,7 +4,7 @@ const { logger } = require("./filesystem")
/** Checks if a port is already in use
*
*/
function checkPort(port, callback) {
function checkPortSync(port, callback) {
portfinder.getPort({ port: port, stopPort: port }, (err, res) => {
if (err !== null) {
logger.error(`Port ${port} already in use`);
@@ -15,6 +15,14 @@ function checkPort(port, callback) {
});
}
function checkPort(port) {
return portfinder.getPortPromise({ port: port, stopPort: port });
}
function getFreePort(startPort) {
return portfinder.getPortPromise({ port: startPort });
}
/** Performs a fetch request, with a configurable timeout
*
*/
@@ -34,6 +42,8 @@ async function fetchWithTimeout(resource, options = {}) {
}
module.exports = {
getFreePort: getFreePort,
checkPort: checkPort,
checkPortSync: checkPortSync,
fetchWithTimeout: fetchWithTimeout
}