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

connect-dispatcher

v1.3.0

Published

convetions-over-configuration dispatcher middleware in ES6

Readme

connect-dispatcher

Codeship Status for unknownexception/connect-dispatcher

Disclaimer. connect-dispatcher is outdated. See koajs, rest, react-router or other frameworks.

Why?

  1. Conventions over configurations. DRY routes.
  2. It has to be simple. A controller returns data to a views, rendering the different type of views depend on the context. You can process the first response on the server-side, then render the same view in the browser.
  3. Caching controllers, views, or the entire html. Cache stored in a memory, but there is no a big deal about moving to Redis.
  4. Small size footprint, just single file src/dispatcher.js written with typed Flow ES6.

For more information see examples and tests.

Getting started

First, install packages via npm:

npm install connect-dispatcher

Second, create a new file app.js:

var app = require('connect')(),
  dispatcher = require('connect-dispatcher');

app.use(dispatcher());

app.listen(3001);

By default the connect-dispatcher trying to look for controller with the name app/controllers/pages_controller.js whithing exported method index. So to avoid 404 error we need as simple controller as this pages_controller.js:

var pages = module.exports;

pages.index = function () {
  return this.asText('Hello World!');
};

It produces simple plain-text response to the browser, without view rendering. To enable template-engine rendering, change code to:

var pages = module.exports;

pages.index = function () {
  return {
    title:'Hello World!'
  };
};

and add to project a jade template. By default, the location of this view is app/views/pages/index.jade

h1= title

After server is restarted, refresh the browser to see html response (if you are not using livereload):

<h1> Hello World! </h1>

Options

Full config example:

app.use(dispatcher({
  routes: { '/' : '/pages/home'},
  controllersPath:  'application/controllers',
  getControllerFile: function (name) { return name + '_controller.js';},
  viewsPath: 'application/views', // by default it depends on NODE_ENV (useful for grunt usemin)
  getViewFile: function (controller, action) { return controller + '/' + action + '.jade';}
  cache : true, // by default it depends on NODE_ENV
  renderHook: function (ctx) { console.log ('before render ' + ctx.request.controller + '/' + ctx.request.action)}

}))

TODO

-[] DI; -[] Remove all dependencies;