Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yorkie/bender-api
API wrapper for Bender
https://github.com/yorkie/bender-api
Last synced: 5 days ago
JSON representation
API wrapper for Bender
- Host: GitHub
- URL: https://github.com/yorkie/bender-api
- Owner: yorkie
- License: mit
- Created: 2014-02-24T15:44:55.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-08-28T03:19:14.000Z (about 5 years ago)
- Last Synced: 2024-10-19T19:34:27.029Z (24 days ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bender-api
API wrapper for [Bender](https://github.com/vigour-io/bender).
## Installation
```sh
npm install bender-api
```## Usage
```js
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('Hello world!
');
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);
});
```