ritterim/sparkles — pull request #2 by khalidabuhakmeh (2014-10-31 18:22:13+00:00)
Title: Added request node package

This will allow us to ping TeamCity at the following url:

```text
http://{build-server}/httpAuth/app/rest/builds?locator=branch:default:any,running:true
```

This was my initial spike. Note that I have **moment** as another package dependency.

```javascript
var request = require('request');
var moment = require('moment');
var interval = 1000; /* ms */

var pingTeamcityBuildQueue = function() {

var options = {
url: 'http://######/httpAuth/app/rest/builds?locator=branch:default:any,running:true',
method: 'GET',
auth: {
'user': '****',
'pass': '****'
},
json: true,
headers : {
'Accept' : 'application/json',
'Content-Type' : 'application/json'
}
};

console.log('waiting for teamcity...');
request.get(options, function (error, response, body) {
if (error) {
console.log(error);
} else {
console.log("current # of builds " + "(" + moment().format("dddd, MMMM Do YYYY, h:mm:ss a") + ") : " + body.count );
toggleLights(body.count);
}
setTimeout(pingTeamcityBuildQueue, interval);
});
}

pingTeamcityBuildQueue();
```