Nest - modern, fast, powerful node.js web framework (@maxmind)
npm install nestjs-maxmind- Description
- Installation
- Examples
- License
``sh`
npm install nestjs-maxmind maxmind
You can also use the interactive CLI
`sh`
npx nestjs-modules
`sh`
npx geoip2-cli --download --licenseKey=MAXMIND_LICENSE_KEY
`ts
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 {}
`
`ts
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 {}
`
`ts
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');
}
}
``
MIT