0.0.11 • Published 9 years ago

bt-find-server v0.0.11

Weekly downloads
3
License
ISC
Repository
github
Last release
9 years ago

Find Server function.

Installation

$ npm install bt-find-server

or alternatively using Yarn package manager

$ yarn add bt-find-server

Usage

// Require bt-find-server module as findServer.
var findServer = require('bt-find-server');

// Setup server array.
// Must be an array of objects containing url and priority values.
var serverArray = [{
	"url": "http://doesNotExist.boldtech.co",
	"priority": 1
}, {
	"url": "http://boldtech.co",
	"priority": 7
}, {
	"url": "http://offline.boldtech.co",
	"priority": 2
}, {
	"url": "http://npmjs.com",
	"priority": 4
}];

// Call findServer() function passing in serverArray
findServer(serverArray).then(function(results) {
	// If successful, results will be an object containing:
	// { url: 'http://npmjs.com', priority: 4, statusCode: 200 }
}).catch(function(error) {
	// If unsuccessful, error contains message:
	  // Failed, all servers offline - If no servers responded with valid status code.
	  // Invalid server array - If no valid urls/priority values were provided.
	  // Fatal error, findserver() failed with message: \n + error.message
});

Options

under construction

Testing

$ npm install
$ npm test

License

ISC