archive
/
tstatic
Archived
1
Fork 0

Add opt-in dir listing

This commit is contained in:
Jake Howard 2017-02-13 08:50:51 +00:00
parent d32cec782d
commit 04c7647687
3 changed files with 12 additions and 1 deletions

View File

@ -33,6 +33,7 @@
"express-winston": "=2.1.2",
"helmet": "=3.4.0",
"opbeat": "=4.7.0",
"serve-index": "=1.8.0",
"winston": "=2.3.0"
},
"devDependencies": {

View File

@ -5,5 +5,6 @@ module.exports = {
PORT: process.env.PORT || 5000,
IN_TEST,
IN_PRODUCTION: process.env.NODE_ENV === 'production',
DIR_LIST: process.env.DIR_LIST,
BASIC_AUTH_ENABLED: process.env.BASIC_AUTH_USERNAME && process.env.BASIC_AUTH_PASSWORD
};

View File

@ -7,6 +7,7 @@ const consts = require('./consts');
const compression = require('compression');
const helmet = require('helmet');
const serveIndex = require('serve-index');
const opbeat = require('opbeat').start({
active: consts.IN_PRODUCTION
});
@ -19,7 +20,15 @@ const basicAuth = require('./basic-auth');
// Custom Middleware
app.use(logging);
app.use(basicAuth);
app.use(staticFiles.indexHandle);
if (consts.DIR_LIST) {
app.use(serveIndex(consts.SERVE_DIR, {
icons: true
}));
} else {
app.use(staticFiles.indexHandle);
}
app.use(staticFiles.static);
app.use(handle404);