https://github.com/aamiralam/fastest-server-check
Node module to find fastest available server among the list given server array
https://github.com/aamiralam/fastest-server-check
chaijs mocha-chai node-module nodejs
Last synced: 5 months ago
JSON representation
Node module to find fastest available server among the list given server array
- Host: GitHub
- URL: https://github.com/aamiralam/fastest-server-check
- Owner: AamirAlam
- License: gpl-3.0
- Created: 2020-06-11T12:39:55.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T20:36:43.000Z (over 3 years ago)
- Last Synced: 2025-03-21T22:14:48.257Z (about 1 year ago)
- Topics: chaijs, mocha-chai, node-module, nodejs
- Language: JavaScript
- Size: 373 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fastest-server-check
Node module to find fastest available server with minimum priority among the list given list of servers with priority
# features
- Find online server with minimum priority from given list of servers
- Light weight and fast
- JavaScript based
# install
Run following commands into the module directory to use the module
```
npm install -S
npm install -D
```
# Usage
Find fastest server by making following async call
```
var fastestServerCheck = require('./index'); # path to the module
const check = async () => {
const servers = [
{url:"http://google.com", priority:4},
{url:"http://doesNotExist.boldtech.co", priority:1},
{url:"http://boldtech.co", priority:7},
{url:"http://offline.boldtech.co", priority:2},
{url:"https://github.com/AamirAlam/fastest-server-check",priority:5}]
try {
var result = await fastestServerCheck(servers);
# result will be the online server object with minimun priority
console.log(result);
/*
{ success:true, message:"Server found",url:"http://google.com", priority:4}
*/
} catch (error) {
console.log(error)
/*
{ success:false, message:"All servers are offline"}
*/
}
}
check();
```
## Test
Start unit test of module components by following command
```
npm test
```