5
0
mirror of https://github.com/cwinfo/hyperboria-peers.git synced 2024-11-22 13:00:38 +00:00

publish javascript api as an npm module

This commit is contained in:
ansuz 2016-06-19 10:51:53 +02:00
parent 41d4682c8a
commit f35456b940
2 changed files with 54 additions and 0 deletions

View File

@ -70,3 +70,32 @@ By following this scheme, we make it possible for users to programmatically find
Credential files must end with `.k`. Credential files must end with `.k`.
Otherwise, you can name your file whatever you want, but for simplicity's sake, avoid characters which will need to be escaped at the command line. Otherwise, you can name your file whatever you want, but for simplicity's sake, avoid characters which will need to be escaped at the command line.
## Javascript API
Peering credentials in this repository can be accessed via a simple Javascript API (using Nodejs).
It's available as a module on npm:
`npm install hyperboria-peers`
### Usage
```Javascript
var Peers = require("./index.js");
/* return a list of public peers located in North America */
Peers.filter(function (creds, path) {
return path.indexOf('NA') !== -1;
});
/* return a list of public keys */
Peers.map(function (creds, path) {
return creds[Object.keys(creds)[0]].publicKey;
});
/* the underlying data is exposed in a nested json structure */
console.log(Peers.peers);
console.log(Peers.peers.NA.us.california);
```

25
package.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "hyperboria-peers",
"version": "1.0.0",
"description": "A geographically sorted list of public peering credentials for joining Hyperboria",
"main": "index.js",
"scripts": {
"test": "node tests.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/hyperboria/peers.git"
},
"keywords": [
"hyperboria",
"fc00",
"public",
"peers"
],
"author": "ansuz",
"license": "AGPL-3.0",
"bugs": {
"url": "https://github.com/hyperboria/peers/issues"
},
"homepage": "https://github.com/hyperboria/peers#readme"
}