beatsaber-metrics-tracker/src/index.ts

27 lines
777 B
TypeScript
Raw Normal View History

2023-10-27 14:54:11 +00:00
import { InfluxDB } from "@influxdata/influxdb-client";
2023-10-27 11:10:20 +00:00
import * as dotenv from "dotenv";
dotenv.config();
2023-10-27 14:54:11 +00:00
export const INFLUXDB_URL = process.env.INFLUXDB_URL;
export const INFLUXDB_ORG = process.env.INFLUXDB_ORG;
export const INFLUXDB_BUCKET = process.env.INFLUXDB_BUCKET;
export const INFLUXDB_TOKEN = process.env.INFLUXDB_TOKEN;
2023-10-27 11:10:20 +00:00
if (!INFLUXDB_URL || !INFLUXDB_ORG || !INFLUXDB_BUCKET || !INFLUXDB_TOKEN) {
throw new Error("Missing InfluxDB environment variables");
}
2023-10-27 14:54:11 +00:00
const influxClient = new InfluxDB({
2023-10-27 11:10:20 +00:00
url: INFLUXDB_URL,
token: INFLUXDB_TOKEN,
2023-10-27 14:54:11 +00:00
});
export const InfluxWriteAPI = influxClient.getWriteApi(
INFLUXDB_ORG,
INFLUXDB_BUCKET,
"ms"
);
export const InfluxQueryAPI = influxClient.getQueryApi(INFLUXDB_ORG);
require("./updateData");
require("./api");