Compare commits
7 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c117eebf6 | ||
|
|
bb13a5d36a | ||
|
|
a92d2171c8 | ||
|
|
424530699f | ||
|
|
c329b09ba0 | ||
|
|
505d08d6d0 | ||
|
|
872d95619d |
3 changed files with 21 additions and 5 deletions
|
|
@ -1,7 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
const Swagger = require('swagger-client-promises'),
|
||||
Stream = require('./lib/stream');
|
||||
Stream = require('./lib/stream'),
|
||||
pkg = require('../package.json');
|
||||
|
||||
class HeaderKey {
|
||||
|
||||
constructor(key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
apply(obj, authorizations) {
|
||||
obj.headers['X-AIO-Key'] = this.key;
|
||||
obj.headers['User-Agent'] = `AdafruitIO-Node/${pkg.version} (${process.platform} ${process.arch} ${process.version})`;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Client {
|
||||
|
||||
|
|
@ -11,7 +26,7 @@ class Client {
|
|||
this.port = 80;
|
||||
this.username = username || false;
|
||||
this.key = key || false;
|
||||
this.swagger_path = '/api/docs/api.json';
|
||||
this.swagger_path = '/api/docs/v1.json';
|
||||
this.success = function() {};
|
||||
this.failure = function(err) { throw err; };
|
||||
|
||||
|
|
@ -25,10 +40,11 @@ class Client {
|
|||
|
||||
this.swagger = new Swagger({
|
||||
url: `http://${this.host}:${this.port}${this.swagger_path}`,
|
||||
debug: true,
|
||||
success: this._defineGetters.bind(this),
|
||||
failure: this.failure,
|
||||
authorizations: {
|
||||
HeaderKey: new Swagger.ApiKeyAuthorization('X-AIO-Key', this.key, 'header')
|
||||
HeaderKey: new HeaderKey(this.key)
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "adafruit-io",
|
||||
"version": "4.2.5",
|
||||
"version": "4.4.0",
|
||||
"description": "Adafruit IO Client, Local Server, & io.adafruit.com TLS Tunnel",
|
||||
"bin": "./cli.js",
|
||||
"main": "index.js",
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 39cd5ef820d8c0b830018c27a7a78d7c32cc5aeb
|
||||
Subproject commit 0981108294f7a37d85443deccf3650bbdd200d43
|
||||
Loading…
Reference in a new issue