mc-tracker/src/influx/influx.ts
Liam 88472c81e9
Some checks failed
Publish Docker Image / docker (push) Successful in 42s
deploy / deploy (push) Has been cancelled
add auto invalidation of dns cache
2024-01-03 09:46:46 +00:00

35 lines
751 B
TypeScript

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,
});
this.writeApi = this.influx.getWriteApi(
Config.influx.org,
Config.influx.bucket,
"ms"
);
logger.info("InfluxDB initialized");
}
/**
* Write a point to the database.
*
* @param point the point to write
*/
public writePoint(point: Point) {
this.writeApi.writePoint(point);
}
}