New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

nestjs-geoip2

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-geoip2

Nest - modern, fast, powerful node.js web framework (@geoip2)

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

NestJS GeoIP2

NPM Version Package License

Table of Contents

Description

Integrates MaxMind GeoIP2 with Nest

Installation

npm install nestjs-geoip2 @maxmind/geoip2-node

You can also use the interactive CLI

npx nestjs-modules

Examples

npx geoip2-cli --download --licenseKey=MAXMIND_LICENSE_KEY

GeoIP2Module.forRoot(options, connection?)

import { Module } from '@nestjs/common';
import { GeoIP2Module } from 'nestjs-geoip2';
import { AppController } from './app.controller';
import { join } from 'path';

@Module({
  imports: [
    GeoIP2Module.forRoot({
      config: {
        file: join(process.cwd(), 'geoip2-cli', 'GeoLite2-City.mmdb'),
      },
    }),
  ],
  controllers: [AppController],
})
export class AppModule {}

GeoIP2Module.forRootAsync(options, connection?)

import { Module } from '@nestjs/common';
import { GeoIP2Module } from 'nestjs-geoip2';
import { AppController } from './app.controller';
import { join } from 'path';

@Module({
  imports: [
    GeoIP2Module.forRootAsync({
      useFactory: () => ({
        config: {
          file: join(process.cwd(), 'geoip2-cli', 'GeoLite2-City.mmdb'),
        },
      }),
    }),
  ],
  controllers: [AppController],
})
export class AppModule {}

InjectGeoIP2(connection?)

import { Controller, Get, } from '@nestjs/common';
import { InjectGeoIP2, GeoIP2 } from 'nestjs-geoip2';

@Controller()
export class AppController {
  constructor(
    @InjectGeoIP2() private readonly geoIP2: GeoIP2,
  ) {}

  @Get()
  async getHello() {
    return await this.geoIP2.city('8.8.8.8');
  }
}

License

MIT

Keywords

nest

FAQs

Package last updated on 04 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts