Sava
A tiny module that lets you check whether the server is responding or not
Usage
const ServiceAvailability = ; let health = url: 'https://domain.com/content/ping.jpg' body_size: 276423 timeout: 30 interval: 60 max_ping: 800 max_errors_streak: 10 messages: timeout: 'Server does not respond' not_found: 'Wrong url' high_ping: 'Ping is %s ms above the maximum' wrong_body_size: 'Wrong response body size: %s bytes' init_failed: 'Initialization failed, the file is not available' health health health;
If you dont't want to calculate body_size
of your reference file, you can call init()
method, that will do that for you:
health; health;
Received body_size
will be saved to a '.cache' file.