0.2.1 • Published 10 years ago

bender-api v0.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

bender-api

API wrapper for Bender.

Installation

npm install bender-api

Usage

var http = require('http');
var bender = require('bender-api')({
  host: 'localhost',
  port: 1729
});

http.createServer(function (req, res) {
  res.writeHead(200, { 'content-type': 'text/html' });
  res.write('<h1>Hello world!</h1>');
  res.end();
}).listen(function () {
  var port = this.address().port;
  var host = this.address().host || '127.0.0.1';
  setInterval(function () {
    bender.registrations.register({
      app: 'hello-world',
      version: '1.0.0',
      host: host,
      port: port
    });

    bender.registrations.list('hello-world', '1.0.0', function (err, registrations) {
      if (err) {
        console.error('Error: ' + err.message);
        return;
      }

      registrations = registrations.registrations;
      console.log('Registrations:');
      registrations.forEach(function (registration) {
        console.log('  ' + registration.host + ':' + registration.port);
      });
      console.log();
    });
  }, 3000);
});
0.2.1

10 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago