0.0.12 • Published 1 year ago

nestjs-influx2 v0.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Description

InfluxDB module for Nest based on the official InfluxDb package.

Installation

npm install nest-influx2 --save

or

yarn add nest-influx2

Usage

Register module:

import { Module } from "@nestjs/common";
import { InfluxModule, InfluxModuleOptions } from "nest-influx2";
import { UtilsModule } from "./utils/utils.module";
import { ConfigService } from "./utils/config/config.service";

@Module({
    imports: [
        InfluxModule.forRootAsync({
            imports: [UtilsModule],
            inject: [ConfigService],
            useFactory: async (
                config_servie: ConfigService
            ): Promise<InfluxModuleOptions> => {
                return {
                    url: config_servie.get("INFLUX_HOST"),
                    token: config_servie.get("INFLUX_TOKEN"),
                };
            }
        }),
        TrafficModule
    ],
    controllers: [AppController],
    providers: [AppService]
})
export class AppModule {}

Get access to InfluxDbService in some your service:

@Injectable()
export class TrafficService {
    constructor(private readonly influx_service: InfluxService) {}

    public async getLastDay(): Promise<ResponseDto> {
        const results = await this.influx_service.query(`
            select MEAN(*) from traffic WHERE time > now() - 1d GROUP BY time(10m);
        `);

        return results.map(pointToDto);
    }
}
0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago