billy-http-express
A Billy service that creates an
Express 4 HTTP server.
Install
$ npm install billy-http-express
Usage
var Application = require('billy').Application;
var HttpService = require('billy-http-express');
var app = new Application();
app.service(HttpService);
app.config('http.port', 50123);
app.start();
The actual server is started after all services have been loaded, so
registering any middleware or setting up of express should happen after this
service via the http
dependencies.
function MyService(http)
{
http.use(cookieParser());
}
This can be done in a separate service following this one, or via specifying a
module via the http.server
config.
Injectables
New dependencies that you can use after adding this service:
tag | type | description | notes |
---|
http | express | The express application | Setup routes, middleware, etc with this object |
Configs
New dependencies that you can use after adding this service:
config | type | description | default value | notes |
---|
http.port | number | Port to listen on for HTTP connections | process.env.PORT , 8123 1 | |
http.secret | string | Server-side secret | 'supersecret' | Used for securing cookies. |
http.webroot | string | Path to directory of static files to serve | null | Optional. If not set, will not start the static server. |
http.server | function | Server startup module | null | Optional IoC-injected module to start after registering server. |
1 Will use the PORT
environment variable if available, e.g. on Heroku.
Tern Support
The source files are all decorated with JSDoc3-style
annotations that work great with the Tern code inference
system. Combined with the Node plugin (see this project's .tern-project
file), you can have intelligent autocomplete for methods in this library.
Testing
Testing is done with Tape and can be run
with the command npm test
.
Testing is done with Travis CI.
License
Copyright 2014 Brandon Valosek
billy-http-express is released under the MIT license.