This commit is contained in:
Lee
2024-01-03 07:25:17 +00:00
parent 4ed5d2af84
commit e603f65fdc
18 changed files with 1350 additions and 639 deletions

34
src/influx/influx.ts Normal file
View File

@ -0,0 +1,34 @@
import { InfluxDB, Point, WriteApi } from "@influxdata/influxdb-client";
import Config from "../../data/config.json";
import { logger } from "../utils/logger";
export default class Influx {
private influx: InfluxDB;
private writeApi: WriteApi;
constructor() {
logger.info("Loading influx database");
this.influx = new InfluxDB({
url: Config.influx.url,
token: Config.influx.token,
});
logger.info("InfluxDB initialized");
this.writeApi = this.influx.getWriteApi(
Config.influx.org,
Config.influx.bucket,
"ms"
);
}
/**
* Write a point to the database.
*
* @param point the point to write
*/
public async writePoint(point: Point): Promise<void> {
this.writeApi.writePoint(point);
}
}