Change server behavior to allow for testing

This commit is contained in:
Petr Sloup 2016-03-09 11:09:06 +01:00
parent 717b176dc7
commit 7ca7fc721f

View file

@ -25,7 +25,8 @@ module.exports = function(opts, callback) {
callback = callback || function() {}; callback = callback || function() {};
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production' &&
process.env.NODE_ENV !== 'test') {
app.use(morgan('dev')); app.use(morgan('dev'));
} }
@ -67,10 +68,16 @@ module.exports = function(opts, callback) {
}); });
}); });
app.listen(process.env.PORT || opts.port, function() { var server = app.listen(process.env.PORT || opts.port, function() {
console.log('Listening at http://%s:%d/', console.log('Listening at http://%s:%d/',
this.address().address, this.address().port); this.address().address, this.address().port);
return callback(); return callback();
}); });
setTimeout(callback, 1000);
return {
app: app,
server: server
};
}; };