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

abc-router

v0.0.7

Published

router

Readme

abc-router

Router utilities package for generating URLs and managing routing in the ABC system. This package provides functions for creating consistent URL patterns across different application types.

📦 Installation

pnpm add abc-router

🚀 Key Features

1. URL Generation

  • Generate consistent router paths for applications
  • Support for different app types (single, state, parent)
  • Query parameter handling and URL encoding

2. Study Link Generation

  • Create study links for practice tests
  • Support for full-length tests
  • State-specific URL generation

3. Flexible Routing

  • Dynamic path building based on parameters
  • Clean URL generation with proper formatting
  • Support for nested routing structures

📚 API Reference

generateRouterApp(options)

Generate a router path based on provided parameters.

import { generateRouterApp } from "abc-router";

const path = generateRouterApp({
  app: "test-app",
  state: "california",
  linkTo: "resolve",
  payload: { resultId: 123, attemptNumber: 1 },
});
// Returns: "/test-app/california/resolve?resultId=123&attemptNumber=1"

Parameters:

  • app?: string - The application name
  • state?: string - The state parameter
  • linkTo?: string - The target link (will be cleaned if starts with '/')
  • payload?: Record<string, any> - Query parameters to append to the URL

Examples:

// Basic app routing
generateRouterApp({
  app: "asvab",
  linkTo: "practice",
});
// Returns: "/asvab/practice"

// State-specific routing
generateRouterApp({
  app: "cdl",
  state: "california",
  linkTo: "test",
});
// Returns: "/cdl/california/test"

// With query parameters
generateRouterApp({
  app: "asvab",
  linkTo: "result",
  payload: { score: 85, time: "30min" },
});
// Returns: "/asvab/result?score=85&time=30min"

// Clean linkTo (removes leading slash)
generateRouterApp({
  app: "test",
  linkTo: "/resolve",
});
// Returns: "/test/resolve"

genStudyLink(options)

Generate study links for practice tests and full-length tests.

import { genStudyLink } from "abc-router";

const studyLink = genStudyLink({
  appShortName: "asvab",
  tag: "practice-questions",
  fullTest: false,
});
// Returns: "asvab-practice-questions-practice-test"

Parameters:

  • appShortName: string - Short name of the application
  • tag: string - Tag to categorize the test
  • fullTest?: boolean - Whether it's a full-length test (default: false)
  • state?: string - State parameter (optional)
  • isParent?: boolean - Whether it's a parent app (default: false)

Examples:

// Practice test link
genStudyLink({
  appShortName: "asvab",
  tag: "math",
  fullTest: false,
});
// Returns: "asvab-math-practice-test"

// Full-length test link
genStudyLink({
  appShortName: "asvab",
  tag: "comprehensive",
  fullTest: true,
});
// Returns: "full-length-asvab-comprehensive-practice-test"

// State-specific link
genStudyLink({
  appShortName: "cdl",
  tag: "general",
  state: "california",
});
// Returns: "cdl-california-general-questions"

// Parent app link (cleaned URL)
genStudyLink({
  appShortName: "easyprep",
  tag: "practice",
  isParent: true,
});
// Returns: "practice-practice-test"

handleLink(options)

Handle link generation for state-specific routing.

import { handleLink } from "abc-router";

const link = handleLink({
  appShortName: "asvab",
  tag: "math",
  state: "california",
});
// Returns: "california/asvab-math-questions"

Parameters:

  • appShortName: string - Short name of the application
  • tag: string - Tag to categorize the test
  • state?: string - State parameter (optional)

genStateLink(options)

Generate state-specific links with leading slash.

import { genStateLink } from "abc-router";

const stateLink = genStateLink({
  appShortName: "asvab",
  tag: "math",
  state: "california",
});
// Returns: "/california/asvab-math-questions"

Parameters:

  • appShortName: string - Short name of the application
  • tag: string - Tag to categorize the test
  • state?: string - State parameter (optional)

🔧 URL Patterns

Application Routing Patterns

  1. Basic App: /app/link
  2. State App: /app/state/link
  3. With Query: /app/link?param=value

Study Link Patterns

  1. Practice Test: appShortName-tag-practice-test
  2. Full Test: full-length-appShortName-tag-practice-test
  3. State Specific: appShortName-state-tag-questions
  4. Parent App: tag-practice-test (cleaned)

🧪 Testing

# Run tests
pnpm test

# Run tests with coverage
pnpm test:coverage

# Run tests once
pnpm test:run

🔧 Development

# Build package
pnpm build

# Development mode with watch
pnpm dev

# Type checking
pnpm check-types

# Lint
pnpm lint

# Clean dist
pnpm clean

📦 Dependencies

Production Dependencies

  • query-string - Query string parsing and formatting
  • abc-constants - Constants and configurations
  • abc-model - Data models and types

Development Dependencies

  • @repo/eslint-config - ESLint configuration
  • @types/node - Node.js types
  • vitest - Testing framework
  • @vitest/coverage-v8 - Coverage reporting
  • jsdom - DOM environment for tests

📋 Type Definitions

interface IPropsRouterApp {
  app?: string;
  state?: string;
  linkTo?: string;
  payload?: Record<string, any>;
}

interface IPropsGenStudyLink {
  appShortName: string;
  appName?: string;
  tag: string;
  fullTest?: boolean;
  state?: string;
  isParent?: boolean;
}

🔄 Usage Examples

Complete Workflow Example

import { generateRouterApp, genStudyLink, genStateLink } from "abc-router";

// Generate app router path
const appPath = generateRouterApp({
  app: "asvab",
  state: "california",
  linkTo: "practice",
  payload: { topic: "math", level: "intermediate" },
});

// Generate study link
const studyLink = genStudyLink({
  appShortName: "asvab",
  tag: "math-practice",
  fullTest: false,
  state: "california",
});

// Generate state link
const stateLink = genStateLink({
  appShortName: "asvab",
  tag: "math",
  state: "california",
});

console.log(appPath); // "/asvab/california/practice?topic=math&level=intermediate"
console.log(studyLink); // "asvab-california-math-practice-questions"
console.log(stateLink); // "/california/asvab-math-questions"

📄 License

MIT