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 🙏

© 2024 – Pkg Stats / Ryan Hefner

expressway

v0.3.2

Published

A modular MVC microframework for Node.js Express and your impatience

Downloads

8

Readme

Expressway (beta)

Expressway is an extensible, MEAN microframework for Node.js, designed to be completely modular. It is heavily influenced by Taylor Otwell's Laravel for PHP and Google's front-end framework, AngularJS.

npm install breachofmind/expressway --save
# Or, for cool kids:
yarn add breachofmind/expressway

Features

  • Open source foundation. Like Laravel, Expressway believes in using well-tested open-source components to make up it's core code. Core components include Express, Mongoose, NodeMailer, Passport, Commander CLI, and many common Express middleware modules.
  • Angular-style Dependency Injection. Also known as IOC (Inversion of control), Expressway allows you to declare services that can be injected into your functions and class methods.
  • Cutting edge. Expressway is written in ES2015 using classes and inheritance. This makes it easy to extend core classes to overwrite or enhance existing functionality.
  • Not opinionated. Developers are anal. Some like src, some like lib. Expressway is designed to be agnostic to your application's structure.
  • Big or Little. Your project could be as simple as a couple routes or massive with many controllers and routes. Expressway can be as organized or disorganized as you want.
  • Controller and Middleware classes. Separate your middleware stacks and business logic into composable and configurable modules.
  • The Missing CLI. Need to quickly see your route stack, services and models? You need a CLI for that.

Route Stack output

Dependency Injection

Quite possibly the most useful feature is Expressway's IOC implementation, which is borrowed almost exactly from AngularJS.

  1. Define a service.
  2. Add the service name to a function's arguments.
  3. Call the function using app.call(function).
  4. Profit.
app.service('profit', "No more require()!");

function myFunction(profit) {
    return profit;
}
app.call(myFunction); // "No more require()"!

This is a very simple example. Imagine how useful this is when it's available in your controller routes:

class MyController extends expressway.Controller
{
    /**
    * MyController.index route.
    * GET /
    */
    index(request,response,next,profit) {
        return profit;
    }
}

Services can be anything - strings, functions, objects, etc.

Usage

Yeoman generator

If you just want to get started with a sensible structure, the Expressway Yeoman generator is the way to go.

npm install breachofmind/expressway-generator -g
mkdir myApp && cd myApp
yo expressway myApp

Quick and Dirty

  • Install the package using npm install breachofmind/expressway.
  • Create an entry file:
// expressway.js
var expressway = require('expressway');
var app = expressway({
    rootPath: __dirname,
});

// Add some services.
function motivationalQuote() {
    return `A nation that separates it's warriors from 
    its scholars will have its fighting done by fools 
    and its thinking done by cowards.`;
}

app.service(motivationalQuote);

// Expressway apps have a "root" app.
// Any extensions you might add later are mounted to this root app.
app.root.routes = [
    {
        // Routes are added in a declarative manner.
        "GET /" : function(request,response,next) {
            return response.send("Hello World");
        },
        // Anonymous routes allow for dependency injection.
        "GET /quote" : function(request,response,next,motivationalQuote) {
            return response.send( motivationalQuote() );
        },
        // As your app gets bigger, you might want to add a controller.
        "GET /:model" : "ModelController.fetchAll",
        
        // You may want to stack middleware on a route.
        "POST /:model/:id" : [
            // The name of a middleware to pass through.
            "ModelRequest", 
            // An anonymous middleware.
            function(request,response,next) {
                console.log('middleware test');
                next();
            },
            // Add finally, the controller method I wanted.
            "ModelController.save"
        ]
    },
    // A simple "NotFound" middleware in case nothing is matched.
    'NotFound'
];

// Start the server.
app.start();
  • Run the file: node expressway.js
  • Build something interesting.

Documentation

The Wiki is where it's at.
I'll be adding more documentation very soon as the API smooths out.

Testing

mocha test