Return JSON with current status and disconnects history
Run with defaults
docker run -p 3010:3010 --name internet-check \
-v internet-check:/home/node/app/data \
assorium/js-internet-status-api:latest
Or use environment variables
docker run -p 3010:3010 --name internet-check \
-v internet-check:/home/node/app/data \
-e CHECK_WEBSITE=https://example.com -e RELEVANCE_TIMEOUT=1 \
assorium/js-internet-status-api:latest
#port app will be launched at
const PORT = process.env.PORT || 3010
#interval to check connection in seconds
const INTERVAL = +process.env.INTERVAL * 1000 || 10000;
#website to check connection
const CHECK_WEBSITE = process.env.CHECK_WEBSITE || 'https://google.com';
#timeout in seconds
const CHECK_TIMEOUT = +process.env.CHECK_TIMEOUT * 1000 || 5000;
#retries
const CHECK_RETRIES = +process.env.CHECK_RETRIES || 2;
#this time in hours data will be stored
const RELEVANCE_TIMEOUT = +process.env.RELEVANCE_TIMEOUT * 60 * 60 || 24 * 60 * 60;
JSON API | GET /
{
success: true,
serverTS: 1581347597,
currentStatus: true, //current connections status: true|false
lastTs: 4861, //last disconnect seconds ago
archive: [ //history of disconnects
{
start: 1581342736,
finish: 1581342756,
duration: 20
}
]
}