30 lines
612 B
TypeScript
30 lines
612 B
TypeScript
|
import { InfluxDB } from "@influxdata/influxdb-client";
|
||
|
|
||
|
/**
|
||
|
* Creates an InfluxDB client
|
||
|
*
|
||
|
* @param token the influx token
|
||
|
* @param url the url of the influx instance
|
||
|
* @param org the org of the influx instance
|
||
|
* @param bucket the bucket of the influx instance
|
||
|
* @returns
|
||
|
*/
|
||
|
function createInfluxClient(
|
||
|
token: string,
|
||
|
url: string,
|
||
|
org: string,
|
||
|
bucket: string
|
||
|
) {
|
||
|
const client = new InfluxDB({
|
||
|
url: url,
|
||
|
token: token,
|
||
|
});
|
||
|
|
||
|
return {
|
||
|
influxWriteClient: client.getWriteApi(org, bucket, "ms"),
|
||
|
influxQueryClient: client.getQueryApi(org),
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export { createInfluxClient };
|