2.1.0 • Published 10 years ago

comws v2.1.0

Weekly downloads
57
License
MIT
Repository
github
Last release
10 years ago

comws

Expressive middleware for node.js using generators via co to make node applications more enjoyable to write. Comws middleware flow in a stack-like manner exactly like koa ones. Use of generators also greatly increases the readability and robustness of your application.

Travis Build Status NPM module NPM downloads

Installation

npm install comws --save

Comws is supported in all versions of node > 4.

Getting started

See all examples in example folder to get started.

Open an issue if you have any question or suggestion.

Example

const CoMws = require('comws');
const mws = new CoMws();

mws.use(function *(next){
  this.result += ' hello';
  yield next();
});

mws.use(function *(next){
  this.result += ' world';
  yield next();
});

const ctx = {result: 'yet another'};

mws.run(ctx).then(function() {
  //ctx.result === 'yet another hello world'
});

Use multiple middlewares

Starting from version 2.1, you can also use multiple middleware in the same use call:

const CoMws = require('comws');
const {mw1, mw2} = require('middlewares');

const mws = new CoMws();

mws.use(mw1, mw2);

or also chain use calls:

const CoMws = require('comws');
const {mw1, mw2} = require('middlewares');

const mws = new CoMws();

mws.use(mw1).use(mw2);

Running tests

$ npm install && npm test

License

The MIT License (MIT)

Copyright (c) 2016 parro-it

2.1.0

10 years ago

2.0.3

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.1

11 years ago

1.0.0

11 years ago