express-boot
v0.0.3
Published
A simple Express middleware to start and stop the server.
Downloads
5
Maintainers
Readme
express-boot
A simple Express middleware to start and stop the server.
##Install
sudo npm install --save express-boot
##Usage
var app = require('express')();
var boot = require('express-boot');
/*...*/
//At the end, start the server
if(require.main === module){
boot(app).start();
} else {
//In case you want to use app in your tests.
module.exports = app;
}
Then run:
npm start
If you want to use app.set
to set your port then just pass app
to boot()
Socket.io
var app = require('express')();
var boot = require('express-boot')(app);
var io = require('socket.io')(boot().server);
##API
boot(app, port)
- Accepts the Express app and/or port number
boot().start()
- Starts the Express server
boot().close()
- Closes the Express server
boot().server
- Returns the http server
boot().app
- Returns the Express app
boot.version
- Returns boot's version
boot.config(opt)
- Configures boot
Options
//default
{
appName: 'Express app',
port: process.env.PORT || 3000,
debug: true
}
##Test
npm test
##Changelog
Latest:
0.0.1
- Initial Commit
0.0.2
- Updated readme
0.0.3
- Port now defaults to
port.env.PORT || 3000
. - Updated readme