-
Notifications
You must be signed in to change notification settings - Fork 0
/
middleware.js
32 lines (32 loc) · 1.12 KB
/
middleware.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var serveStatic = require('serve-static');
var path = require('path');
var _ = require('lodash');
module.exports = function(express, apps, skipRouter) {
var sitesServed = {};
var usesServed = {};
apps.forEach(function(app) {
if (!sitesServed[app.sitePath]) {
express.use(serveStatic(app.sitePath));
sitesServed[app.sitePath] = true;
}
if (app.uses) {
app.uses.forEach(function(using) {
if (!usesServed[using]) {
express.use('/' + path.basename(using) + '/images/', serveStatic(path.join(using, 'images')));
}
});
}
express.use('/' + app.name + '/images/', serveStatic(path.join(app.path, 'images')));
});
if (!process.env.DERBY_RENDERER) {
if (!skipRouter) {
express.use('/croc/images/', serveStatic(__dirname + '/source/croc/images'));
}
apps.forEach(function(app) {
express.use(app.router());
_.forEach(app.packages, function(packApp) {
express.use(packApp.router());
});
});
}
};