1.5.0 • Published 4 years ago
web-uptimer v1.5.0
Install
$ npm i web-uptimer
Setup
const up = require('web-uptimer');
const uptimer = new up.Uptimer({ timeout: 30000}); //5m
//You can use also client: 'node-fetch' or 'got'
Logging
const uptimer = new up.Uptimer({ timeout: 1000, pingLog: true }) //logging on the console when ping url
const uptimer = new up.Uptimer({ timeout: 1000, pingLog: true, pingMessage: '{url} was pinged'}) //https://example.com was pinged | {url} = the url who is pinged
Example
/**
* Pinging url every 8s
* Stopping after 4s
* Only Example */
const uptimer = new up.Uptimer({ timeout: 8000, client: 'node-fetch' });
uptimer.add('https://example.com', '123456789123456789') //id/name: string
uptimer.startAll();
setTimeout(() => {
uptimer.substring('https://example.com', '123456789123456789');
uptimer.restart('123456789123456789'); //update fetching
}, 4000)
Get all
uptimer.allById('123456789123456789').then(array => console.log(array));
uptimer.all().then(array => console.log(array));
Clients
Endpoints
Value | Param | Output |
---|---|---|
add | url, id | true |
substring | url, id | true |
allById | id | array |
start | id | true |
stop | id | true |
restart | true | |
all | array | |
startAll | true | |
stopAll | true | |
restartAll | true |