diff options
author | Johannes Zellner <johannes@cloudron.io> | 2017-02-05 06:08:43 -0800 |
---|---|---|
committer | Johannes Zellner <johannes@cloudron.io> | 2017-02-05 06:08:43 -0800 |
commit | 490f71d70fa24042a80175129e8ba7ba12d95c17 (patch) | |
tree | 6f3e0292effcfeb2915deffe9a7ead0099b4e046 | |
parent | dc7353941f0e61145cd957df3955bc6f2d001cec (diff) | |
download | Surfer-490f71d70fa24042a80175129e8ba7ba12d95c17.tar.gz Surfer-490f71d70fa24042a80175129e8ba7ba12d95c17.tar.zst Surfer-490f71d70fa24042a80175129e8ba7ba12d95c17.zip |
Serve up folder listings
-rwxr-xr-x | server.js | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -15,6 +15,7 @@ var express = require('express'), | |||
15 | multipart = require('./src/multipart'), | 15 | multipart = require('./src/multipart'), |
16 | mkdirp = require('mkdirp'), | 16 | mkdirp = require('mkdirp'), |
17 | auth = require('./src/auth.js'), | 17 | auth = require('./src/auth.js'), |
18 | serveIndex = require('serve-index'), | ||
18 | files = require('./src/files.js')(path.resolve(__dirname, process.argv[2] || 'files')); | 19 | files = require('./src/files.js')(path.resolve(__dirname, process.argv[2] || 'files')); |
19 | 20 | ||
20 | var app = express(); | 21 | var app = express(); |
@@ -30,10 +31,13 @@ router.get ('/api/healthcheck', function (req, res) { res.status(200).send(); | |||
30 | // welcome screen in case / does not serve up any file yet | 31 | // welcome screen in case / does not serve up any file yet |
31 | router.get('/', function (req, res) { res.status(200).sendFile(path.join(__dirname, '/app/welcome.html')); }); | 32 | router.get('/', function (req, res) { res.status(200).sendFile(path.join(__dirname, '/app/welcome.html')); }); |
32 | 33 | ||
34 | var rootFolder = path.resolve(__dirname, process.argv[2] || 'files'); | ||
35 | |||
33 | app.use(morgan('dev')); | 36 | app.use(morgan('dev')); |
34 | app.use(compression()); | 37 | app.use(compression()); |
35 | app.use('/_admin', express.static(__dirname + '/app')); | 38 | app.use('/_admin', express.static(__dirname + '/app')); |
36 | app.use(express.static(path.resolve(__dirname, process.argv[2] || 'files'))); | 39 | app.use(express.static(rootFolder)); |
40 | app.use(serveIndex(rootFolder, { icons: true })); | ||
37 | app.use(bodyParser.json()); | 41 | app.use(bodyParser.json()); |
38 | app.use(bodyParser.urlencoded({ extended: false, limit: '100mb' })); | 42 | app.use(bodyParser.urlencoded({ extended: false, limit: '100mb' })); |
39 | app.use(cookieParser()); | 43 | app.use(cookieParser()); |