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

express-declarative-routing

v0.0.2

Published

Declarative Routing for Express.js

Readme

express-declarative-routing

declarative routing for express.js

NPM Package

npm install express-declarative-routing

we need your help!

A few things on the roadmap:

  • full testing
  • cover all features of express.js routing

getting started

  1. routes are declared as nested objects, leaf values point to controller methods
  • object properties are route element names
  • '_middlware' can be used to declare what middleware is available to subroutes definitions
  • '_middlewareName1_middlewareName2' can be used to declare that subroutes are using the middleware
  • '$' in routes will be replaced with ':', which signifies a wildcard in express routing
  1. run build routes
  • this builds middleware in front of certain routes as required
  • creates a list of functions which will build the routes later
  • also conveniently outputs a table of the routes it's built and what middleware applies to each

Example:

declare routes (for example in /routes/some_routes.coffee)

controller = require(./controller)
module.export =
  route_a:
    subroute_b:
      _middleware: [ middlware 1 ] # middleware shared  by all routes in subroute_b
      get: controller.getAB
      put: controller.putAB
    subroute_c:
      post: controller.getAC
    _groupName:
      _middleware: [ middleware1, middleware2 ] # middleware shared by all routes in groupName
      subroute_d:
        $variable:
          get: controller.getAD
      subroute_e:
        get: controller.getAE
        post: controller.postAE
  route_b:
    all: controller.getB

build routes (usually server.js/coffee, where the express app is available)

routing = require("./lib/routing")
app = express()
routing.buildRoutes(app,
  '/mountRoute' : [
    require("./some_routes")
  ]
)

this results in the following routes:

/mountRoute/route_a/subroute_b GET PUT
/mountRoute/route_a/subroute_c GET
/mountRoute/route_a/subroute_c/subroute_d/:variable GET
/mountRoute/route_a/subroute_c/subroute_e/ GET POST
/mountRoute/route_b GET POST PUT DELETE OPTIONS