mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-24 08:29:53 +00:00
feature(server) remove extra layer to express
This commit is contained in:
parent
d487273990
commit
b99befe1b1
2 changed files with 7 additions and 35 deletions
|
|
@ -9,7 +9,9 @@
|
|||
cloudcmd = require(DIR_LIB + 'cloudcmd'),
|
||||
exit = require(DIR_SERVER + 'exit'),
|
||||
config = require(DIR_SERVER + 'config'),
|
||||
express = require(DIR_SERVER + 'express'),
|
||||
express = require('express'),
|
||||
tryRequire = require('tryrequire'),
|
||||
logger = tryRequire('morgan'),
|
||||
io = require('socket.io');
|
||||
|
||||
/**
|
||||
|
|
@ -27,11 +29,7 @@
|
|||
config('ip') ||
|
||||
'0.0.0.0',
|
||||
|
||||
app = express.getApp({
|
||||
auth : config('auth'),
|
||||
username: config('username'),
|
||||
password: config('password')
|
||||
});
|
||||
app = express();
|
||||
|
||||
server = http.createServer(app);
|
||||
|
||||
|
|
@ -40,6 +38,9 @@
|
|||
socket: io.listen(server)
|
||||
}));
|
||||
|
||||
if (logger)
|
||||
app.use(logger('dev'));
|
||||
|
||||
if (port <= 0 || port > 65535)
|
||||
exit('cloudcmd --port: %s', 'port number could be 1..65535');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var DIR = __dirname + '/../../',
|
||||
DIR_LIB = DIR + 'lib/',
|
||||
|
||||
Util = require(DIR_LIB + 'util'),
|
||||
|
||||
tryRequire = require('tryrequire'),
|
||||
|
||||
express = require('express'),
|
||||
logger = tryRequire('morgan'),
|
||||
|
||||
app = express();
|
||||
|
||||
exports.getApp = function(middleware) {
|
||||
var isArray = Util.type.array(middleware);
|
||||
|
||||
if (logger)
|
||||
app.use(logger('dev'));
|
||||
|
||||
if (isArray)
|
||||
middleware.forEach(function(middle) {
|
||||
app.use(middle);
|
||||
});
|
||||
|
||||
return app;
|
||||
};
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue