const Influx = require('influx') module.exports = function init () { const influx = new Influx.InfluxDB({ host: process.env.INFLUX_HOST || '172.18.0.1', database: process.env.INFLUX_DATABASE || 'dummy-data', schema: [ { measurement: 'temperature', fields: { value: Influx.FieldType.INTEGER }, tags: [ 'deviceId' ] }, { measurement: 'air_humidity', fields: { value: Influx.FieldType.INTEGER }, tags: [ 'deviceId' ] }, { measurement: 'ground_humidity', fields: { value: Influx.FieldType.INTEGER }, tags: [ 'deviceId' ] }, { measurement: 'airforce', fields: { value: Influx.FieldType.INTEGER }, tags: [ 'deviceId' ] } ] }) influx.createDatabase(process.env.INFLUX_DATABASE) .catch(console.error) return influx }