mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(express) tryrequire -> require
This commit is contained in:
parent
8ad5359b5b
commit
f8973e26c0
1 changed files with 9 additions and 13 deletions
|
|
@ -8,25 +8,21 @@
|
|||
|
||||
tryRequire = require('tryrequire'),
|
||||
|
||||
express = tryRequire('express'),
|
||||
express = require('express'),
|
||||
logger = tryRequire('morgan'),
|
||||
|
||||
app = express && express();
|
||||
app = express();
|
||||
|
||||
exports.getApp = function(middleware) {
|
||||
var isArray = Util.type.array(middleware);
|
||||
|
||||
if (app) {
|
||||
if (logger)
|
||||
app.use(logger('dev'));
|
||||
|
||||
if (isArray)
|
||||
middleware.forEach(function(middle) {
|
||||
app.use(middle);
|
||||
});
|
||||
|
||||
app.use(express.static(DIR));
|
||||
}
|
||||
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