This is a node.js module, which allows you to check, if different types of servers are online. Check the other sections for information about the installation and usage. 💾📡
You can install it like every other npm package. Simply run npm install server-reachability
in your terminal.
After installing, you can begin to use it. At first you should import it, like:
const sr = require('server-reachability');
The isReachable
function is asynchronous and gives back a boolean (true
or false
). So you have to await it. You have to give a hostname, a port and a timeout in milliseconds to it. If values are missing it will log that and allways return false
. Code example:
// Imports...
async function fn() {
console.log(await sr.isReachable('google.com', 80, 5000));
}
fn();
Output:
true
If you have questions, you can ask me everytime on my Discord. Just click the badge ;)