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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ezzy-express-mvc

v3.1.5

Published

A complete mvc infrastructure to render pages from a specific directory based.

Readme

ezzy-express-mvc

Greenkeeper badge Build Status Coverage Status

A complete mvc infrastructure to render pages from a specific directory.

You can use this class to recurse through a directory that contains Controllers, Models and Views to prepare an application with multiple routes mapped accordingly. This utility maps all controllers to their respective views and provides the necessary models to generate the response.

When the application initializes, an instance to the controller is registered in the express application. Then, at the time of the request, an instance of the respective model gets injected into the view of the application. While the model is injected, the code checks for any JS and CSS assets that exist in the respective assets directory. During production, this directory is only checked once, but in development, the directory is checked on every request. Additionally, sass and compass have been implemented to allow dynamic CSS generation to the corresponding /css folder.

For example, you can structure your directory in this manner:

  • /src/ (root)

http://localhost:9000/

  • /src/HomeController.js (home app)
  • /src/HomeModel.js
  • /src/homeView.hbs
  • /src/homeAssets/ (home app static assets)
  • /src/homeAssets/js/
  • /src/homeAssets/css/
  • /src/homeAssets/images/
  • /src/homeAssets/scss/ (home app sass/compass sources)

http://localhost:9000/login/

  • /src/login/LoginController.js (login app)
  • /src/login/LoginModel.js
  • /src/login/loginView.hbs
  • /src/login/loginAssets/ (login app static assets)
  • /src/login/loginAssets/js/
  • /src/login/loginAssets/css/
  • /src/login/loginAssets/images/

Other Utilities

  • /src/partials/customPartial.hbs (other handlebars tools)
  • /src/layouts/baseLayout.hbs
  • /src/helpers/customHelper.hbs

And now in your localhost.js file, you can simply invoke it like this:

const ExpressMvc = require('ezzy-express-mvc');
new ExpressMvc(__dirname + '/src')
  .promise // we have to wait for file detection.
  .then(app => app.listen(9000));

If you'd like to bind other applications to the same port, simply use:

const ExpressMvc = require('ezzy-express-mvc');
new ExpressMvc(__dirname + '/src')
  .promise
  .then(app => app.bindExpressMvc(__dirname + '/anotherDirectory'))
  .then(app => app.listen(9000));

Constructor Configuration

    /**
     * @param {string} directory The directory of the mvc sources.
     * @param {Function|Function[]} middleware Any middleware that's required.
     * @param {function({HttpBasics}):boolean} requestFilter The filter function that decides if this instance of the MVC application will handle the request.
     * @param {RegExp} domainReg The regular expression for the domain or the function that will check if the route will be resolved.
     * @param {string[]|string} statics The static routes to assign before anything. Note: These routes are directories matching the context of the folders within the application.
     * @param {boolean} bind404 If we should bind a 404 route after all the controllers are bound to avoid continuing to any other applications.
     * @param {string} customErrorDir The custom error directory where the application can find [error-status].html files.
     * @param {Function|Function[]} globalMiddleware The global middleware to use on this and all other bound MVC applications.
     * @param {express} expressDependency The express instance to be used if a certain version is required.
     * @param {string} partials The name of the partials directories.
     * @param {string} layouts The name of the layouts directories.
     * @param {string} helpersFile The file containing handlebars helpers.
     * @param {string[]} partialsDirectories Any additional directories to look for partials.
     * @param {string[]} layoutsDirectories Any additional directories to look for layouts.
     * @param {string[]} otherStatics Any additional directories to use as static files.
     */
    const defaultConfig = {
      directory: undefined,
      middleware: undefined,
      domainReg: /.*/,
      statics: undefined,
      bind404: false,
      requestFilter: undefined,
      customErrorDir: 'errors',
      globalMiddleware: undefined,
      expressDependency: undefined,
      partials: undefined,
      layouts: undefined,
      helpersFile: undefined,
      partialsDirectories: [],
      layoutsDirectories: [],
      otherStatics: []
    };