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

@alteredconstants/express-router

v0.1.2

Published

In Express 5, [there is currently no way](https://github.com/expressjs/express/discussions/5961) to get access to the route information of a router from within the app or router objects themselves. This makes it essentially impossible to inspect all the r

Readme

Express Router With Route Inspection

In Express 5, there is currently no way to get access to the route information of a router from within the app or router objects themselves. This makes it essentially impossible to inspect all the routes in one place which is especially frustrating if they are spread across many nested routers and/or files.

This library provides a thin wrapper over the Router constructor from Express which makes it possible to track the route configuration for later logging.

Installation

npm install @alteredconstants/express-router

You will also have to install Express if you haven't already.

npm install express

Example

// routes.js
import {
	createRouter,
	setRouteRequestHandlerName,
} from "@alteredconstants/express-router";

// Define your middleware however you'd like.
const users = [{ id: 1, name: "Steve" }];
const products = [{ id: 1, name: "Golden Apple" }];
const authUser = (req, res, next) => next();
const authProducts = (type) =>
	// Use this function to set a dynamic handler name in the output.
	setRouteRequestHandlerName(
		(req, res, next) => next(),
		`authProducts(${type})`,
	);
const canViewProducts = authProducts("view");
const canAddProduct = authProducts("add");
const getUsers = (req, res) => res.send(users);
const getProducts = (req, res) => res.send(products);
const getProduct = (req, res) => res.send(product[0]);
const addProduct = (req, res) => res.send({ message: "Added!" });

// Create and compose routers together.
const productsRouter = createRouter({
	middleware: [canViewProducts],
	routes: [
		["get", "/", getProducts],
		["post", "/", canAddProduct, addProduct],
		["get", "/:id", getProduct],
	],
});
export const appRouter = createRouter({
	middleware: [authUser],
	routes: [
		["get", "/api/users", getUsers],
		["use", "/api/products", productsRouter],
	],
});
// index.js
import express from "express";
import { appRouter } from "./routes.js";

// Add the routers to your app.
const app = express();
app.use(appRouter);

Then, if you ever want to inspect your routes, you can write a simple script like:

// print-routes.js
import { getRoutesGenerator } from "@alteredconstants/express-router";
import { appRouter } from "./routes.js";

// Or use `getRoutes` if you'd prefer an array.
for (const { method, path, handlerNames } of getRoutesGenerator(appRouter)) {
	console.log(method, path, `[${handlerNames.join(", ")}]`);
}

Then run the script with the AC_EXPRESS_ROUTER_TRACKING environment variable set to a non-empty value to enable the tracking (disabled by default):

AC_EXPRESS_ROUTER_TRACKING=true node print-routes.js

It will generate this output for this example:

GET /api/users [authUser, getUsers]
GET /api/products [authUser, authProducts(view), getProducts]
POST /api/products [authUser, authProducts(view), authProducts(add), addProduct]
GET /api/products/:id [authUser, authProducts(view), getProduct]