Skip to content

mrspartak/js-internet-status-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js-internet-status-api

Return JSON with current status and disconnects history

Docker Cloud Automated build Docker Cloud Build Status Docker Pulls

Latest Github tag

Docker run

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

Environment variables

#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;

API

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
		}
	]
}

Graphs | GET /graph.html image