mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 17:04:16 +00:00
refactor(express) getApp
This commit is contained in:
parent
0093c8e650
commit
27313074b6
1 changed files with 6 additions and 9 deletions
|
|
@ -13,6 +13,7 @@
|
|||
express = main.require('express'),
|
||||
httpAuth = main.require('http-auth'),
|
||||
logger = main.require('morgan'),
|
||||
Util = main.util,
|
||||
crypto = main.crypto,
|
||||
basic,
|
||||
oldPass,
|
||||
|
|
@ -20,8 +21,8 @@
|
|||
app = express && express();
|
||||
|
||||
exports.getApp = function(middleware) {
|
||||
var i, n, middle,
|
||||
config = main.config,
|
||||
var isArray = Util.isArray(middleware),
|
||||
config = main.config,
|
||||
auth = config.auth;
|
||||
|
||||
if (app) {
|
||||
|
|
@ -33,14 +34,10 @@
|
|||
app.use(httpAuth.connect(basic));
|
||||
}
|
||||
|
||||
if (middleware) {
|
||||
n = middleware.length;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
middle = middleware[i];
|
||||
if (isArray)
|
||||
middleware.forEach(function(middle) {
|
||||
app.use(middle);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return app;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue