/**
 * @file dbService.js
 * @author Radim Buráň (xburan03@stud.fit.vutbr.cz)
 */

const { PrismaClient } = require('@prisma/client');
const {InfluxDB, Point, HttpError} = require('@influxdata/influxdb-client');
require('dotenv').config();

const prisma = new PrismaClient();

const influxUrl = process.env.INFLUX_URL;
const influxToken = process.env.INFLUX_TOKEN;
const INFLUX_ORG = process.env.INFLUX_ORG;
const INFLUX_BUCKET = process.env.INFLUX_BUCKET;

const influxDB = new InfluxDB({url : influxUrl, token : influxToken});

function influxWriteAPI() {
    return influxDB.getWriteApi(INFLUX_ORG, INFLUX_BUCKET, 's');
}

function influxQueryAPI() {
    return influxDB.getQueryApi(INFLUX_ORG);
}

module.exports = {
    prisma,
    influxQueryAPI,
    influxWriteAPI,
    influxDB,
    INFLUX_ORG,
    INFLUX_BUCKET,
}