From c16d47666c5c4702e596ae6e76dc6fe569408a57 Mon Sep 17 00:00:00 2001 From: Haris Razis Date: Wed, 16 Dec 2020 09:21:35 +0200 Subject: [PATCH] =?UTF-8?q?=20=F0=9F=94=A8=20Change=20conn=20exports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/connections/influx_conn.js | 4 ++-- server/connections/mongo_conn.js | 0 server/connections/redis_conn.js | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 server/connections/mongo_conn.js diff --git a/server/connections/influx_conn.js b/server/connections/influx_conn.js index 9d2dbc9..f52ca68 100644 --- a/server/connections/influx_conn.js +++ b/server/connections/influx_conn.js @@ -8,7 +8,7 @@ const client = new InfluxDB({ token: influx_token, }); -const writeApi = client.getWriteApi( +const write = client.getWriteApi( influx_org, influx_bucket ); @@ -16,4 +16,4 @@ const writeApi = client.getWriteApi( const queryApi = client.getQueryApi(influx_org); console.log(chalk.greenBright.bold('Connected to influx!')) -module.exports = {writeApi, queryApi} \ No newline at end of file +module.exports = {writeApi: write, queryApi} \ No newline at end of file diff --git a/server/connections/mongo_conn.js b/server/connections/mongo_conn.js new file mode 100644 index 0000000..e69de29 diff --git a/server/connections/redis_conn.js b/server/connections/redis_conn.js index 80e3e94..f503316 100644 --- a/server/connections/redis_conn.js +++ b/server/connections/redis_conn.js @@ -1,14 +1,18 @@ const redis = require('redis'); const chalk = require('chalk'); -const {redis_user, redis_password, redis_host, redis_port} = require('../config/keys') +const {redis_host, redis_port} = require('../config/keys') -const client = redis.createClient(`redis://${redis_host}:${redis_port}`); +const pub = redis.createClient(`redis://${redis_host}:${redis_port}`); +const sub = pub.duplicate(); -client.on('error', function (error) { +pub.on('error', (error) => { console.error(error); }); -console.log(chalk.greenBright.bold('Connected to redis!')) +pub.on('ready', () => { + pub.flush; + console.log(chalk.greenBright.bold('Connected to redis!')) +}) -module.exports = {client} \ No newline at end of file +module.exports = {pub, sub} \ No newline at end of file