express-composer
v1.0.3
Published
A composition library to help organize your express routes and handlers
Downloads
7
Readme
express-composer
A composition library built by extending express
Modules
<a name="module_express-composer"></a>
express-composer
method for creating an express application with express-compose mixin
Example
var expressComposer = require('express-composer');
- express-composer
- expressComposer() ⇒ app ⏏
- static
- .extend(app) ⇒ app
- .handle(handlers, scopeProvider) ⇒ function
- .error(handlers, scopeProvider) ⇒ function
- .validate(validate, scopeProvider) ⇒ function
- inner
- ~scopeArg : Object | function | Promise.<Object>
- ~requestHandlers : function | Array.<function()>
- ~pathArg : String
- ~appOptions : Object
- ~routerOptions : Object
- ~requestMethod : object
- ~requestMethods : object
- ~routeScore : Object
- ~routerScore : Object
- ~appScore : Object
- static
- expressComposer() ⇒ app ⏏
expressComposer() ⇒ app ⏏
Creates an extended express app
Kind: Exported function
Example
var express = require('expressComposer'),
app = express();
expressComposer.extend(app) ⇒ app
Extends an express app if it was not created with express-compose
Kind: static method of expressComposer
| Param | Type | Description | | --- | --- | --- | | app | function | express app |
Example
var express = require('express'),
expressComposer = require('express-composer'),
app = express();
expressComposer.extend(app);
expressComposer.handle(handlers, scopeProvider) ⇒ function
Creates an express middle ware handler that will iterate through composers handlers
Kind: static method of expressComposer
| Param | Type | Description | | --- | --- | --- | | handlers | Array.<function()> | function | | | scopeProvider | ScopeProvider | the scope of these handlers |
expressComposer.error(handlers, scopeProvider) ⇒ function
Creates an express middle ware error handler that will iterate through composers error handlers
Kind: static method of expressComposer
| Param | Type | Description | | --- | --- | --- | | handlers | Array.<function()> | function | | | scopeProvider | ScopeProvider | the scope for these handlers |
expressComposer.validate(validate, scopeProvider) ⇒ function
Create an express middle ware that validates an incoming request
Kind: static method of expressComposer
| Param | Type | Description | | --- | --- | --- | | validate | function | validation function | | scopeProvider | ScopeProvider | scope variable |
expressComposer~scopeArg : Object | function | Promise.<Object>
Kind: inner typedef of expressComposer
expressComposer~requestHandlers : function | Array.<function()>
Kind: inner typedef of expressComposer
expressComposer~pathArg : String
Kind: inner typedef of expressComposer
expressComposer~appOptions : Object
Express application options passed into express
Kind: inner typedef of expressComposer
Properties
| Name | Type | Description | | --- | --- | --- | | dotFiles | String | Option for serving dotfiles. Possible values are �allow�, �deny�, and �ignore� | | etag | Boolean | Enable or disable etag generation | | extentions | Boolean | Sets file extension fallbacks. | | index | Object | String | Sends directory index file. Set false to disable directory indexing. | | lastModified | Boolean | Set the Last-Modified header to the last modified date of the file on the OS. Possible values are true or false. | | maxAge | Boolean | Set the max-age property of the Cache-Control header in milliseconds or a string in ms format | | redirect | Number | Redirect to trailing �/� when the pathname is a directory. | | setHeaders | function | Function for setting HTTP headers to serve with the file. |
expressComposer~routerOptions : Object
Options passed into express [Router]{http://expressjs.com/api.html#router}
Kind: inner typedef of expressComposer
Properties
| Name | Type | Description | | --- | --- | --- | | caseSensitive | Boolean | Enable case sensitivity. | | mergeParams | Boolean | Preserve the req.params values from the parent router. If the parent and the child have conflicting param names, the child�s value take precedence. | | strict | Boolean | Enable strict routing. |
expressComposer~requestMethod : object
Kind: inner typedef of expressComposer
Properties
| Name | Type | Description | | --- | --- | --- | | validator | function | function used to validate the request | | preHandlers | requestHandlers | handlers that will be called during execution of the route | | scope | scopeArg | scope values to inject into the context of the handlers | | errorHandlers | requestHandlers | handlers called if there is an error during the request | | name | String | name of the method | | description | String | description about what this method does |
expressComposer~requestMethods : object
Kind: inner typedef of expressComposer
Properties
| Name | Type | Description | | --- | --- | --- | | checkout | requestMethod | requestHandlers | handles checkout requests | | connect | requestMethod | requestHandlers | handles connect requests | | copy | requestMethod | requestHandlers | handles copy requests | | delete | requestMethod | requestHandlers | handles delete requests | | get | requestMethod | requestHandlers | handles get requests | | head | requestMethod | requestHandlers | handles head requests | | lock | requestMethod | requestHandlers | handles lock requests | | m-search | requestMethod | requestHandlers | handles m-search requests | | merge | requestMethod | requestHandlers | handles merge requests | | mkactivity | requestMethod | requestHandlers | handles mkactivity requests | | mkcol | requestMethod | requestHandlers | handles mkcol requests | | move | requestMethod | requestHandlers | handles move requests | | notify | requestMethod | requestHandlers | handles notify requests | | options | requestMethod | requestHandlers | handles options requests | | patch | requestMethod | requestHandlers | handles patch requests | | post | requestMethod | requestHandlers | handles post requests | | propfind | requestMethod | requestHandlers | handles propfind requests | | proppatch | requestMethod | requestHandlers | handles proppatch requests | | purge | requestMethod | requestHandlers | handles purge requests | | put | requestMethod | requestHandlers | handles put requests | | report | requestMethod | requestHandlers | handles report requests | | search | requestMethod | requestHandlers | handles search requests | | subscribe | requestMethod | requestHandlers | handles subscribe requests | | trace | requestMethod | requestHandlers | handles trace requests | | unlock | requestMethod | requestHandlers | handles unlock requests | | unsubscribe | requestMethod | requestHandlers | handles unsubscribe requests |
expressComposer~routeScore : Object
Kind: inner typedef of expressComposer
Properties
| Name | Type | Description | | --- | --- | --- | | methods | requestMethods | methods for this route | | preHandlers | requestHandlers | handlers that are executed before a route method | | errorHandlers | requestHandlers | handlers for errors within this route | | scope | scopeArg | scope argument for this route | | name | String | the name of the route | | description | String | a description of the route | | path | pathArg | the path for the route |
expressComposer~routerScore : Object
Kind: inner typedef of expressComposer
Properties
| Name | Type | Description | | --- | --- | --- | | preHandlers | requestHandlers | handlers that are executed during this route | | routes | routeScore | Array.<routeScore> | routes for this router | | errorHandlers | requestHandlers | handles errors tha occurred in this route | | scope | scopeArg | scope options to include in this scope | | routers | routerScore | nested routers | | name | String | name of this route | | description | String | a description of this route | | path | pathArg | the path to this route | | | routerOptions | options for the router |
expressComposer~appScore : Object
Kind: inner typedef of expressComposer
Properties
| Name | Type | Description | | --- | --- | --- | | preHandlers | requestHandlers | handlers that are executed for this app | | errorHandlers | requestHandlers | handles errors tha occurred in this route | | scope | scopeArg | scope options to include in this scope | | routers | routerScore | Array.<routerScore> | nested routers | | name | String | name of this route | | description | String | a description of this route | | | appOptions | options for the router | | | appScore | Array.<appScore> | apps for this app | | path | pathArg | the path for the app | | vhost | String | a vhost routing string | | properties | Object | an object used to set express options |