Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

influxdb-v1

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

influxdb-v1 - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

4

package.json
{
"name": "influxdb-v1",
"version": "1.0.2",
"version": "1.0.3",
"description": "A light-weight library to write data to InfluxDB v1",

@@ -37,5 +37,5 @@ "main": "./src/index.js",

"c8": "^7.3.0",
"pactum": "^2.0.7",
"pactum": "^3.1.3",
"uvu": "^0.3.3"
}
}

@@ -47,2 +47,8 @@ # influxdb-v1

});
// query
const db = influx.db({ url: 'http://influx.url', db: 'database name', username: 'user', password: 'pass' });
await db.query('SELECT * FROM measurement');
await db.flux('from(bucket:"telegraf")');
```

@@ -49,0 +55,0 @@

export interface InfluxOptions {
url: string;
db: string;
username?: string;
password?: string;
}

@@ -27,2 +29,8 @@

write(metrics: Metrics[]): Promise<any>;
/**
* queries data from influx db
*/
query(value: String): Promise<any>;
flux(value: String): Promise<any>;
}

@@ -40,2 +48,9 @@

export function write(options: InfluxOptions, metrics: Metrics[]): Promise<any>;
/**
* queries data from influx db
*/
export function query(options: InfluxOptions, value: String): Promise<any>;
export function flux(options: InfluxOptions, value: String): Promise<any>;
export namespace influx { }

@@ -41,3 +41,3 @@ const rp = require('phin-retry');

}
return rp.post({
const req = {
url: `${this.options.url}/write`,

@@ -48,5 +48,39 @@ qs: {

body: payloads.join('\n')
});
}
if (this.options.username) {
req.auth = { user: this.options.username, pass: this.options.password };
}
return rp.post(req);
}
query(value) {
if (!value) throw new Error('`query` is required');
const req = {
url: `${this.options.url}/query`,
qs: {
db: this.options.db,
q: value
}
};
if (this.options.username) {
req.auth = { user: this.options.username, pass: this.options.password };
}
return rp.get(req);
}
flux(query) {
const req = {
url: `${this.options.url}/api/v2/query`,
headers: {
'Accept': 'application',
'Content-type': 'application/vnd.flux'
},
body: query
};
if (this.options.username) {
req.headers['Authorization'] = `Token ${this.options.username}:${this.options.password}`;
}
return rp.post(req);
}
}

@@ -62,2 +96,10 @@

return new DB(options).write(metrics);
},
query(options, value) {
return new DB(options).query(value);
},
flux(options, query) {
return new DB(options).flux(query);
}

@@ -64,0 +106,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc