express-jefferson
Declarative Express Application Wiring
express-jefferson is a microlibrary for declaratively describing RESTful services. Currently, it allows you to describe your service routes as a map.
// main.jsvar express = jefferson = app = conf = proxies: name: 'Logger' { return { console; ; } } routes: getBeerList: method: 'GET' path: '/beers' middleware: beerlistget sendjson ; ;...
Configuration
- routes: (optional) - An map of routes by name. Each object in the map describes an endpoint to be wired. These endpoints must contain an HTTP method, a path, and an array of middleware functions.
- proxies: (optional) - An array of proxy objects invoked around all middleware functions in order. Each proxy object should have an init() function that accepts a delegate middleware function and returns a new middleware function.
Boilerplate Proxies
Promise-Based Middleware Proxy
require('express-jefferson/proxies/promise-handler')
This proxy accepts promise-based middleware (middleware that accepts two arguments) and wraps them in a promise chain before invoking next().
Installation
$ npm install express-jefferson --save