4.1.1 • Published 7 months ago

@eddaic/nestjs-maxmind-geoip2 v4.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

nestjs-google-maps

Simple NestJS Module to support a @maxmind/geoip2-node client.

Installation

npm install @eddaic/nestjs-maxmind-geoip2

Usage

Initializing

import { MaxmindGeoip2Module } from '@eddaic/nestjs-maxmind-geoip2';
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';

@Module({
  imports: [
    MaxmindGeoip2Module.registerAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        accountId: config.get('MAXMIND_ACCOUNT_ID'),
        licenseKey: config.get('MAXMIND_LICENSE_KEY'),
      }),
    }),
  ],
  providers: [AppService],
})
export class AppModule {}

Calling

import { MaxmindGeoip2Service } from '@eddaic/nestjs-maxmind-geoip2';
import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {
  constructor(private readonly geoip: MaxmindGeoip2Service) {}

  helloWorld() {
    const ip = '123.123.123.123';
    const result = this.geoip.client.city(ip);

    // Or use shorthand functions
    const result2 = this.geoip.city(ip);
  }
}
4.1.1

7 months ago

4.1.0

7 months ago

4.0.0

8 months ago

3.5.0

9 months ago

3.4.1

9 months ago