npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ipgeotrace/nestjs

v0.1.0

Published

NestJS module for IPGeoTrace. Resolves the caller's location once per request and injects it via the @Geo() decorator.

Readme

@ipgeotrace/nestjs

NestJS module for IPGeoTrace. Resolves the caller's location once per request and injects it into your handlers with the @Geo() decorator. Built on @ipgeotrace/client — the secret key stays server-side.

Sign up and grab your API key at ipgeotrace.com.

Install

npm add @ipgeotrace/nestjs @nestjs/common @nestjs/core rxjs reflect-metadata

Usage

Register the module once at the root. It binds a global interceptor that resolves the caller on every request, so nothing else needs wiring.

import { Module } from '@nestjs/common';
import { IpGeoTraceModule } from '@ipgeotrace/nestjs';

@Module({
  imports: [
    IpGeoTraceModule.forRoot({ apiKey: process.env.IPGEOTRACE_API_KEY! }),
  ],
})
export class AppModule {}

Then pull the result into any handler with @Geo():

import { Controller, Get } from '@nestjs/common';
import { Geo, type GeoLookup } from '@ipgeotrace/nestjs';

@Controller('checkout')
export class CheckoutController {
  @Get()
  checkout(@Geo() geo: GeoLookup) {
    const currency = geo.status === 'resolved' ? geo.value?.country?.currency ?? 'USD' : 'USD';
    return { currency };
  }
}

@Geo() gives you a GeoLookup whose status tells you exactly what happened:

  • resolvedvalue carries the data.
  • skipped — the caller's IP was missing, private, loopback, or link-local, so no API call was made.
  • failederror carries the reason (rate_limited, quota_exceeded, …).
  • not_attempted — the interceptor opted out for this request (shouldResolve returned false), or never ran (non-HTTP context).

Skipping requests

Health checks and internal endpoints should not spend lookups. Opt them out with shouldResolve:

IpGeoTraceModule.forRoot({
  apiKey: process.env.IPGEOTRACE_API_KEY!,
  shouldResolve: (req) => !req.url.startsWith('/health'),
});

Private, loopback, and link-local addresses (including IPv4-mapped IPv6) are detected locally and skipped without an API call or quota usage.

Choosing the caller's IP

By default the interceptor uses req.ip, which respects your HTTP adapter's proxy settings (enable trust proxy on Express or trustProxy on Fastify). Override it for full control:

IpGeoTraceModule.forRoot({
  apiKey: process.env.IPGEOTRACE_API_KEY!,
  ipSelector: (req) => req.headers['cf-connecting-ip'] ?? req.ip,
});

Async configuration

Pull the API key (and any client options) from ConfigService or another provider:

IpGeoTraceModule.forRootAsync({
  imports: [ConfigModule],
  inject: [ConfigService],
  useFactory: (config: ConfigService) => ({
    apiKey: config.getOrThrow('IPGEOTRACE_API_KEY'),
    clientOptions: { cache: true, timeoutMs: 3_000 },
  }),
});

Injecting the service directly

IpGeoTraceService is exported from the module and injectable anywhere for explicit lookups (e.g. resolving an IP you already have, or in a queue worker):

import { Injectable } from '@nestjs/common';
import { IpGeoTraceService } from '@ipgeotrace/nestjs';

@Injectable()
export class FraudService {
  constructor(private readonly geo: IpGeoTraceService) {}

  async score(ip: string) {
    const result = await this.geo.resolve(ip);
    return result.ok ? result.value.country?.code : undefined;
  }
}

Opting out of the global interceptor

Pass useGlobalInterceptor: false and apply GeoInterceptor selectively instead:

import { UseInterceptors } from '@nestjs/common';
import { GeoInterceptor } from '@ipgeotrace/nestjs';

@UseInterceptors(GeoInterceptor)
@Controller('checkout')
export class CheckoutController {}

See the @ipgeotrace/client README for caching, retries, timeouts, and batch lookups.