0.1.4 • Published 9 years ago

router-wrapper v0.1.4

Weekly downloads
21
License
-
Repository
-
Last release
9 years ago

router-wrapper

This project wraps the express project router to add a couple of useful functions.

If you pass it a function which returns a promise it'll call the .then() method to handle exceptions for you.

You can also make it bind your handlers to an object of your choice.

Example

// wrap a router
var expressRouter = express.Router();
var router = new Router(expressRouter);

class MyController {
  constructor(router) {
    router
      // make sure the middleware and action get called with the correct `this`
      .context(this)
      // define a route with args to pass to middleware
      .get('/test', this.testAction);
  }

  testAction(request, response) {
    return getAPromiseSomehow()
      .then((x) => response.send(x));
  }
}
0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.0.1

9 years ago