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

routeloader

v0.1.2

Published

This is a node module created to help registering routes for Express Routers.

Readme

#route-loader

This is a node module created to simplify the functionality of the Express node modules router so that developers can code readable and segmented route modules, for each router they create.

Overview

The Express web server (in node) is a great way to configure the server side of web sites and web applications. With Express 4.0 comes the separation of Router objects from the App itself. Because of this change it seemed like a good idea to create an easier way to load routes, and segment them so that managing multiple files or routes didn't explode in one location.

To use the route-loader module all you have to do is require the module, create some routes, and load them into the router.

Installation

// to install in the local directory
npm install routeloader

// to install in the local directory and save to the package.json
npm install routeloader --save

Example Usage

The directory structure is:
/Users/username/node project/
    |__node_modules
        |__route-loader
    |__routers
        |__default-router.js
    |__routes
        |__default-routes.js
    |__server.js (This is the express-js configuration file.)

Server Configuration

In your server configuration all you will need to do is load express, then load the router you've configured in a separate file. In this case it's our default-router.js. Then once loaded, register the router with express. It's as simple as that.

// server.js

// Express
var app = express();
...
var defaultRouter = require('./routers/default-router');
...
app.use('/', defaultRouter);

That's all it takes!

The Router

When creating a router all you need to do is create module file. Call it whatever you want. And then just load the routes.

// default-router.js

// Load express and it's router
var express = require('express');
var router = express.Router();
// Load route-loader
var routeLoader = require('route-loader');

// This is the call that registers the routes from default routes to the router
routeLoader.loadBatch(router, require('../routes/default-routes'));

module.exports = router;

The Routes

In order to register routes you need to create a javascript object that has the route's information configured in it. For the sake of ease, the route-loader comes with some template routes that return the information configured by default, so that you the developer need to interact minimally with the code.

// default-routes.js

// Load the template routes from the route-loader module
templateRoutes = require('route-loader').TemplateRoutes;

var routes = [];
// This adds a javascript object to the routes array with the configured route path of '/' and points that route to the template called index
routes.push(templateRoutes.simpleRender('/', 'index'));

module.exports = routes;

The above code is directly equivalent to this code below:

// default-routes.js

// Load the template routes from the route-loader module
templateRoutes = require('route-loader').TemplateRoutes;

var routes = [];
routes.push(templateRoutes.simpleRender('/', 'index'));
routes.push({ middleware: [function defaultRender(request, response, next) {
 							response.render(response.locals.route.template_path, response.locals.route.template_data);
 						}],
 						path: '/',
 						template_data: {},
 						template_path: 'index',
 						verb: 'get' });
 						
module.exports = routes;

There is a lot more to discuss about these configurations. To read more about it view more in the modules section

Modules