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

smart-google-maps-nestjs

v1.0.0

Published

Production-grade NestJS module for Google Maps APIs

Readme

smart-google-maps-nestjs

npm version License: MIT GitHub stars GitHub issues

Author: Nurul Islam Rimon
Repository: https://github.com/nurulislamrimon/smart-google-maps-nestjs

Production-grade NestJS module for Google Maps APIs.

Features

  • Geocoding: Convert addresses to coordinates
  • Reverse Geocoding: Convert coordinates to addresses
  • Places Search: Search for places by query
  • Place Details: Get detailed information about a place
  • Distance Matrix: Calculate distance and duration between origins and destinations
  • Directions: Get turn-by-turn directions
  • Batch Geocode: Geocode multiple addresses
  • Caching: Optional in-memory caching for API responses
  • Rate Limiting: Prevent exceeding Google API quotas

Installation

npm install smart-google-maps-nestjs

Requirements

  • NestJS 10+
  • @nestjs/common
  • @nestjs/config

Peer dependencies (must be installed):

npm install @nestjs/common @nestjs/config axios

Optional dependencies for caching:

npm install @nestjs/cache-manager cache-manager

Quick Start

1. Import the module

import { Module } from '@nestjs/common';
import { SmartGoogleMapsModule } from 'smart-google-maps-nestjs';

@Module({
  imports: [
    SmartGoogleMapsModule.forRoot({
      apiKey: process.env.GOOGLE_MAPS_API_KEY,
    }),
  ],
})
export class AppModule {}

2. Inject and use the service

import { Injectable } from '@nestjs/common';
import { GoogleMapsService } from 'smart-google-maps-nestjs';

@Injectable()
export class LocationService {
  constructor(private readonly mapsService: GoogleMapsService) {}

  async getCoordinates(address: string) {
    return this.mapsService.geocode(address);
  }
}

Configuration Options

interface SmartGoogleMapsOptions {
  apiKey: string;
  baseUrl?: string;           // Custom API base URL
  timeout?: number;            // Request timeout in ms (default: 10000)
  cache?: {
    enabled: boolean;         // Enable/disable caching
    ttl: number;              // Cache TTL in ms (default: 3600000)
  };
  rateLimit?: {
    enabled: boolean;         // Enable/disable rate limiting
    maxRequests: number;      // Max requests per window
    windowMs: number;         // Time window in ms
  };
}

API Reference

Geocoding

Convert an address to latitude/longitude coordinates.

const result = await mapsService.geocode('1600 Amphitheatre Parkway, Mountain View, CA');
// Returns: { lat: 37.422..., lng: -122.084..., formattedAddress: '...' }

Reverse Geocoding

Convert coordinates to a human-readable address.

const result = await mapsService.reverseGeocode(37.422, -122.084);
// Returns: { formattedAddress: '...', addressComponents: [...], placeId: '...' }

Places Search

Search for places by query.

const results = await mapsService.searchPlaces('restaurants in San Francisco');
// Returns: PlaceSearchResult[]

Place Details

Get detailed information about a place.

const details = await mapsService.getPlace('ChIJN1t_tDeuEmsRUsoyG69frY4');
// Returns: PlaceDetailsResult

Distance Matrix

Calculate distance and duration between two points.

const result = await mapsService.distance('San Francisco, CA', 'Los Angeles, CA', {
  mode: 'driving',
  units: 'metric',
});
// Returns: { distance: '615 km', distanceValue: 615000, duration: '...', durationValue: ... }

Directions

Get turn-by-turn directions.

const result = await mapsService.directions({
  origin: 'San Francisco, CA',
  destination: 'Los Angeles, CA',
  mode: 'driving',
});
// Returns: DirectionsResult with routes, legs, and steps

Batch Geocode

Geocode multiple addresses in batch.

const results = await mapsService.batchGeocode([
  '1600 Amphitheatre Parkway, Mountain View, CA',
  '1 Apple Park Way, Cupertino, CA',
]);
// Returns: GeocodingResult[]

Clear Cache

Clear the cache manually.

await mapsService.clearCache();

Async Configuration

For dynamic or environment-based configuration:

import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { SmartGoogleMapsModule } from 'smart-google-maps-nestjs';

@Module({
  imports: [
    ConfigModule.forRoot(),
    SmartGoogleMapsModule.forRootAsync({
      useFactory: (configService: ConfigService) => ({
        apiKey: configService.get<string>('GOOGLE_MAPS_API_KEY'),
        cache: {
          enabled: true,
          ttl: 3600000,
        },
        rateLimit: {
          enabled: true,
          maxRequests: 50,
          windowMs: 1000,
        },
      }),
      inject: [ConfigService],
    }),
  ],
})
export class AppModule {}

Full Example

import { Module } from '@nestjs/common';
import { SmartGoogleMapsModule, GoogleMapsService } from 'smart-google-maps-nestjs';

@Module({
  imports: [
    SmartGoogleMapsModule.forRoot({
      apiKey: process.env.GOOGLE_MAPS_API_KEY!,
      cache: {
        enabled: true,
        ttl: 3600000, // 1 hour
      },
      rateLimit: {
        enabled: true,
        maxRequests: 50,
        windowMs: 1000,
      },
    }),
  ],
})
export class AppModule {}

License

MIT