nestjs-maxmind
v1.0.2
Published
Nest - modern, fast, powerful node.js web framework (@maxmind)
Downloads
193
Readme
NestJS Maxmind
Table of Contents
Description
Integrates Maxmind with Nest
Installation
npm install nestjs-maxmind maxmind
You can also use the interactive CLI
npx nestjs-modules
Examples
npx geoip2-cli --download --licenseKey=MAXMIND_LICENSE_KEY
MaxmindModule.forRoot(options, connection?)
import { Module } from '@nestjs/common';
import { MaxmindModule } from 'nestjs-maxmind';
import { AppController } from './app.controller';
import { join } from 'path';
@Module({
imports: [
MaxmindModule.forRoot({
config: {
file: join(process.cwd(), 'geoip2-cli', 'GeoLite2-City.mmdb'),
},
}),
],
controllers: [AppController],
})
export class AppModule {}
MaxmindModule.forRootAsync(options, connection?)
import { Module } from '@nestjs/common';
import { MaxmindModule } from 'nestjs-maxmind';
import { AppController } from './app.controller';
import { join } from 'path';
@Module({
imports: [
MaxmindModule.forRootAsync({
useFactory: () => ({
config: {
file: join(process.cwd(), 'geoip2-cli', 'GeoLite2-City.mmdb'),
},
}),
}),
],
controllers: [AppController],
})
export class AppModule {}
InjectMaxmind(connection?)
import { Controller, Get, } from '@nestjs/common';
import { InjectMaxmind, Maxmind } from 'nestjs-maxmind';
@Controller()
export class AppController {
constructor(
@InjectMaxmind() private readonly maxmind: Maxmind,
) {}
@Get()
getHello() {
return this.maxmind.city('8.8.8.8');
}
}
License
MIT