Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

express-layers

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-layers

group express middleware into layers

latest
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

Express Layers

Easily group express middleware into named layers.

Installation

$ npm install express-layers

Usage

app.js:


var express = require('express');
var layers = require('express-layers');

var app = express();
layers(app);  // adds app.lay()

app.use(express.compress());
app.lay('static');  // creates a layer
app.lay('static', express.static(path.join(__dirname, 'public'))); // adds middleware to a layer
app.use(express.router);

myComponent.js:

// this will be executed before express.router
app.lay('static', express.static(path.join(__dirname, 'components', 'myComponent', 'public')));

Running Tests

$ npm install
$ make test

With Components

At Skookum, we organize node.js projects into components (components / feature groups / related user stories). A project might have components like: users, dashboard, marketing, errors, and admin.

In order to keep the components decoupled, each component is responsible for registering its own routes, controller actions, views, models, etc.

Using express-layers allows us to, for example, group all of the static middleware for different components into the same layer. Otherwise, routes for one component might intercept public files for another, since components are loaded one after another.

Keywords

express

FAQs

Package last updated on 17 Dec 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts