Open alonisser opened 9 years ago
you can set in app launcher loadDefaultConfigurations:false
and then load express modules by your self in config/express
this is what is loaded by appolo:
app.set('showStackError', true);
app.use(compression({level: 9}));
app.engine('html', consolidate[this._options.templateEngine]);
app.set('view engine', 'html');
app.set('views', path.join(this._options.root, this._options.viewsFolder));
app.enable('jsonp callback');
app.use(expressValidator());
app.use(bodyParser.urlencoded({
extended: true
}));
if (fs.existsSync(this._options.publicFolder + '/favicon.ico')) {
app.use(favicon(this._options.publicFolder + '/favicon.ico'));
}
app.use(bodyParser.json())
app.use(multer({dest: path.join(this._options.root, this._options.uploadsFolder)}));
app.use(methodOverride());
app.use(cookieParser());
app.use(flash());
app.use(express.static(path.join(this._options.root, this._options.publicFolder)));
if (appolo.environment.type === 'development') {
app.use(morgan('dev'));
}```
Please reopen: For your suggestion to work I need to have all appolo node modules dependencies loaded here as dependencies in my app, using appolo. which is quite strange.. (see the example below)
I think providing a configurable interface to express middlewares would be a better idea.
If some one bumps into this issue: you can hack around this using this code (in config/express):
var morgan = require('../../node_modules/appolo-express/node_modules/morgan');
if (appolo.environment.name == 'development') {
_.forEach(app._router.stack, function (route, idx) {
if (route.name == 'logger') {
app._router.stack.splice(idx, 1);
return true;
}
});
app.use(morgan('dev', {
skip: function (req, res) {
return _.any(_.map(notLoggedRoutes, function(path) {
return _.startsWith(req.url, path);
}));
}
}));
}
appolo-express uses morgan (in launcher) while in development for req, res logging. Since We need to override some verbose logging, I would like to pass a parameter/option to morgan when I call Apollo launch (or whatever.. ) - in this case a function for the
skip
param morgan is accepting. Is there a way to do that without forking appolo and hard coding this :(