Modified manager to new design

This commit is contained in:
Pax1601
2023-12-29 11:28:28 +01:00
parent 7450c9e506
commit 7391006a2f
38 changed files with 1779 additions and 1395 deletions

View File

@@ -11,4 +11,22 @@ function checkPort(port, callback) {
});
}
module.exports = checkPort;
async function fetchWithTimeout(resource, options = {}) {
const { timeout = 8000 } = options;
const controller = new AbortController();
const id = setTimeout(() => controller.abort(), timeout);
const response = await fetch(resource, {
...options,
signal: controller.signal
});
clearTimeout(id);
return response;
}
module.exports = {
checkPort: checkPort,
fetchWithTimeout: fetchWithTimeout
}