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

routing-service

v1.0.0

Published

**routing-service** is a very simple router. Just add routes and callbacks.

Readme

routing-service is a very simple router. Just add routes and callbacks.

This is a es6 module. No compiled version is provided. Install via npm install routing-service or yarn add routing-service.

Don't forget to add history npm-module as a dependency. It is set as peerDependency for convenient updates.

API

  • routingService.onLocationChange(location: Location) - this is run automatically on history change. This function parses provided location and calls matching route's callback
  • routingService.addRoute(shorthand: String, route: String, onVisit: (data: Object, action: String) => {}) => RoutingService - adds route and callback. Returns routingService for chaining.
  • routingService.add404(onRouteNotFound: (action: String) => {}) => RoutingService - adds handler for a case, when matching route could not be found
  • routingService.composeURL(shorthand: String, routeData: { params: Object, query: Object }) => String - returns a url, that matches shorthand route with filled out parameters from routeData. Note that returned string does not include host.
  • routingService.clearRoutes() - cleans up all routes
  • routingService.setURL(url: String) - shorthand for history.push
  • routingService.replaceURL(url: String) - shorthand for history.replace
  • routingService.setLocation(shorthand: String, routeData: Object) - combination of setURL and composeURL
  • routingService.replaceLocation(shorthand: String, routeData: { params: Object, query: Object }) - combination of replaceURL and composeURL

How to use

E.g. in combination with session-controller module

import { Session } from 'session-controller';
import routingService from 'routing-service';

// a list of controller imports
import controllers from './controllers';

window.session = new Session(window.document.getElementById('mount-point'), controllers);

routingService
  .addRoute('home', '/', ({ query }) => {
    // do something with query parameters
    // maybe fetch some data
    // assume payload is the result of that operations
    // ...
    window.session.mountController('HomeController', payload);
  })
  .addRoute('resource', '/resource/:resourceId', ({ params }) => {
    // params will look like { resourceId: ... } for matching route
    // ...
    window.session.mountController('ResourceController', payload);
  })
  .add404(() => {
    window.session.mountController('NotFoundController', {});
  });

// match first route
routingService.onLocationChange(window.location);