Browse Source

Add connections

main
Haris Razis 4 years ago
parent
commit
f808f9690f
No known key found for this signature in database GPG Key ID: 86A4D290ED03FAB4
  1. 19
      server/connections/db_conn.js
  2. 19
      server/connections/influx_conn.js
  3. 14
      server/connections/redis_conn.js

19
server/connections/db_conn.js

@ -1,19 +0,0 @@
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}

19
server/connections/influx_conn.js

@ -0,0 +1,19 @@
const {InfluxDB} = require('@influxdata/influxdb-client')
const chalk = require('chalk')
const {influx_url, influx_token, influx_org, influx_bucket} = require('../config/keys')
const client = new InfluxDB({
url: influx_url,
token: influx_token,
});
const writeApi = client.getWriteApi(
influx_org,
influx_bucket
);
const queryApi = client.getQueryApi(influx_org);
console.log(chalk.greenBright.bold('Connected to influx!'))
module.exports = {writeApi, queryApi}

14
server/connections/redis_conn.js

@ -0,0 +1,14 @@
const redis = require('redis');
const chalk = require('chalk');
const {redis_user, redis_password, redis_host, redis_port} = require('../config/keys')
const client = redis.createClient(`redis://${redis_host}:${redis_port}`);
client.on('error', function (error) {
console.error(error);
});
console.log(chalk.greenBright.bold('Connected to redis!'))
module.exports = {client}
Loading…
Cancel
Save