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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@globolobo/quickroute-address-parser

v1.0.1

Published

NestJS library for parsing Australian addresses using TomTom Search API - works standalone or as NestJS module

Readme

Quickroute Address Parser

A powerful NestJS library for parsing Australian addresses that works both as a NestJS module and as a standalone module.

Features

  • Dual Usage: Full NestJS module OR standalone bundle
  • Australian Focused: Optimized for Australian addresses
  • Provider Support: TomTom integration
  • Built-in Validation: Automatic input validation with warnings
  • Full TypeScript Support: Complete type safety

Design Decision Note:

In a production environment, I would typically recommend implementing either a framework-agnostic solution or a dedicated NestJS module, rather than supporting both approaches. This dual implementation introduces additional build complexity that may not be justified in most use cases.

The choice would ultimately depend on the target audience and integration requirements. While I generally favor simpler, framework-agnostic solutions for broader compatibility, I've implemented both approaches here to showcase comprehensive NestJS expertise and provide maximum flexibility for different integration scenarios.

Installation

npm install @plobolobo/quickroute-address-parser

Usage

Standalone Usage

Perfect for scripts, microservices, or any Node.js application:

import QuickrouteAddressParser from "@plobolobo/quickroute-address-parser/standalone";

const parser = new QuickrouteAddressParser({
  tomtomApiKey: process.env.TOMTOM_API_KEY,
  enableLogging: true,
  timeout: 5000,
});

async function searchAddresses() {
  try {
    const { results, metadata } = await parser.searchAddresses(
      "Collins Street Melbourne",
      5
    );

    console.log(`Found ${metadata.resultCount} results:`);

    results.forEach(({ text, score, address }) => {
      console.log(`- ${text} (Score: ${score})`);
      console.log(`  Suburb: ${address.suburb}, Postcode: ${address.postcode}`);

      if (address.coordinates) {
        const { lat, lon } = address.coordinates;
        console.log(`  📍 ${lat}, ${lon}`);
      }
    });

    if (metadata.warnings.length > 0) {
      console.warn("⚠️ Warnings:", metadata.warnings);
    }
  } catch (error) {
    console.error("❌ Search failed:", error.message);
  } finally {
    await parser.close();
  }
}

searchAddresses();

NestJS Integration

For full NestJS applications with dependency injection:

// app.module.ts
import { Module } from "@nestjs/common";
import { ConfigModule } from "@nestjs/config";
import { QuickrouteAddressParserModule } from "@plobolobo/quickroute-address-parser";

@Module({
  imports: [
    ConfigModule.forRoot(),
    QuickrouteAddressParserModule.register({
      isGlobal: true,
      tomtomApiKey: process.env.TOMTOM_API_KEY,
      baseUrl: process.env.TOMTOM_BASE_URL,
      timeout: parseInt(process.env.REQUEST_TIMEOUT || "30000"),
      retries: parseInt(process.env.RETRY_ATTEMPTS || "3"),
    }),
  ],
  controllers: [AddressController],
})
export class AppModule {}

// address.controller.ts
import { Controller, Get, Query } from "@nestjs/common";
import { QuickrouteAddressParserService } from "@plobolobo/quickroute-address-parser";

@Controller("api/addresses")
export class AddressController {
  constructor(private readonly addressParser: QuickrouteAddressParserService) {}

  @Get("search")
  async search(@Query("q") query: string, @Query("limit") limit = 10) {
    try {
      const { results, metadata } = await this.addressParser.searchAddresses(
        query,
        limit
      );

      return {
        success: true,
        data: results.map(({ text, score, address }) => ({
          text,
          score,
          suburb: address.suburb,
          postcode: address.postcode,
          coordinates: address.coordinates,
        })),
        metadata,
      };
    } catch (error) {
      return {
        success: false,
        error: error.message,
      };
    }
  }

  @Get("provider")
  async getProvider() {
    const providerName = await this.addressParser.getProviderName();
    return { provider: providerName };
  }
}

API Reference

Search Result

interface SearchResult {
  results: Array<{
    text: string;
    score: number;
    address: {
      fullAddress: string;
      streetNumber: string;
      streetName: string;
      suburb: string;
      municipality: string;
      state: string;
      postcode: string;
      country: string;
      coordinates?: { lat: number; lon: number };
    };
  }>;
  metadata: {
    query: string;
    limit: number;
    resultCount: number;
    warnings: string[];
  };
}

Standalone Configuration

interface StandaloneConfig {
  tomtomApiKey: string;
  baseUrl?: string;
  timeout?: number;
  retries?: number;
  enableLogging?: boolean;
}

Examples

standalone-basic.ts - Simple standalone usage

Development

Prerequisites

  • Node.js ≥22.0.0
  • npm ≥9.0.0

Setup

npm install

Commands

# Build the library
npm run build

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

# Clean build artifacts
npm run clean