From ffab802f1d09845c4cad92bff92eb1761a705f12 Mon Sep 17 00:00:00 2001 From: Haris Razis Date: Tue, 8 Dec 2020 18:21:54 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20Add=20db=5Fconn.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/connections/db_conn.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 server/connections/db_conn.js diff --git a/server/connections/db_conn.js b/server/connections/db_conn.js new file mode 100644 index 0000000..a206b0f --- /dev/null +++ b/server/connections/db_conn.js @@ -0,0 +1,19 @@ +const {InfluxDB} = require('@influxdata/influxdb-client') +const chalk = require('chalk') + +const {url, token, org, bucket} = require('../config/dev') + +const client = new InfluxDB({ + url: url, + token: token, +}); + +const writeApi = client.getWriteApi( + org, + bucket +); + +const queryApi = client.getQueryApi(org); +console.log(chalk.yellow('Initialized Database connection...')); + +module.exports = {writeApi, queryApi} \ No newline at end of file