Skip to content

Commit

Permalink
feat: add influx plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
VilemRaska committed Jan 22, 2025
1 parent 87950a4 commit 779b9aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
12 changes: 12 additions & 0 deletions GAPP/apps/gapp-server/src/app/plugins/influxdb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { FastifyInstance } from 'fastify';
import fp from 'fastify-plugin';
import { InfluxDB } from '@influxdata/influxdb-client';

export default fp(async (fastify: FastifyInstance, config) => {
const influxClient = new InfluxDB({
token: '',
url: ''
});

fastify.decorate('influxClient', influxClient);
});
13 changes: 0 additions & 13 deletions GAPP/apps/gapp-server/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Fastify from 'fastify';
import { app } from './app/app';
import { getConfig } from './config';
import { InfluxDB, Point } from '@influxdata/influxdb-client';

const config = getConfig(process.env);

Expand All @@ -17,15 +16,3 @@ server.listen({ port: config.PORT, host: '0.0.0.0' }, (err) => {
process.exit(1);
}
});


const client = new InfluxDB({ url: config.INFLUXDB_HOST, token: config.INFLUXDB_TOKEN });

const writeApi = client.getWriteApi('FikFlights', 'Fik', 'ns');

const point = new Point('measurement');

point.tag('location', 'PRG')
point.intField('humidity', 185);

writeApi.writePoint(point);

0 comments on commit 779b9aa

Please sign in to comment.