Skip to content

Commit 2730442

Browse files
committed
setting uo of dstabase constants
1 parent 522b51b commit 2730442

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

back-end/database/db_delete.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
require('dotenv').config({ path: '../.env'});
22

3-
const {InfluxDB} = require('@influxdata/influxdb-client')
3+
const {InfluxDB} = require('@influxdata/influxdb-client');
44
const { DeleteAPI } = require('@influxdata/influxdb-client-apis');
5-
const CONFIG = require('../../config.json');
65

76

8-
const dbHost = CONFIG.influxdb.host;
9-
const dbPort = CONFIG.influxdb.port;
7+
const dbHost = 'influxdb';
8+
const dbPort = 8086;
9+
10+
const token = process.env.INFLUXDB_API_TOKEN
1011

11-
const token = process.env.API_TOKEN
1212
const url = "http://" + dbHost + ":" + dbPort;
13-
const org = "kneatrum"
13+
const org = process.env.ORG_NAME
1414

1515
const client = new InfluxDB({url, token})
1616
const deleteAPI = new DeleteAPI(client)

back-end/database/db_read.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11

2-
require('dotenv').config({ path: '../.env' });
2+
require('dotenv').config({ path: '../.env'});
33

44
const {InfluxDB} = require('@influxdata/influxdb-client')
55
const { measurements, devices, tags, fields} = require('../constants');
6-
const CONFIG = require('../../config.json');
76

8-
const dbHost = CONFIG.influxdb.host;
9-
const dbPort = CONFIG.influxdb.port;
7+
const dbHost = 'influxdb';
8+
const dbPort = 8086;
9+
const token = process.env.INFLUXDB_API_TOKEN;
1010

11-
12-
const token = process.env.API_TOKEN
1311
const url = "http://" + dbHost + ":" + dbPort;
14-
const org = "kneatrum"
15-
const bucket = "fitbit"
12+
const org = process.env.ORG_NAME
13+
const bucket = process.env.BUCKET_NAME
1614

1715
const client = new InfluxDB({url, token})
1816

back-end/database/db_write.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
require('dotenv').config({ path: '../.env' });
33

44
const {InfluxDB, Point} = require('@influxdata/influxdb-client')
5-
const CONFIG = require('../../config.json');
65

7-
const dbHost = CONFIG.influxdb.host;
8-
const dbPort = CONFIG.influxdb.port;
6+
const dbHost = 'influxdb';
7+
const dbPort = 8086;
8+
const org = process.env.ORG_NAME;
9+
const bucket = process.env.BUCKET_NAME;
10+
const token = process.env.INFLUXDB_API_TOKEN
911

10-
const token = process.env.API_TOKEN
1112
const url = "http://" + dbHost + ":" + dbPort;
12-
let org = "kneatrum"
13-
let bucket = "fitbit"
14-
1513
const client = new InfluxDB({url, token});
1614

1715
let writeClient = client.getWriteApi(org, bucket, 'ns');

0 commit comments

Comments
 (0)