Skip to content

Commit

Permalink
Add baseDir option and pass-through to ecstatic
Browse files Browse the repository at this point in the history
Upgrade ecstatic to version 3.0.0. Use ecstatic's baseDir option
to set a base directory.

See #390
  • Loading branch information
idmontie committed Sep 5, 2017
1 parent 402ad49 commit 6eeb679
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bin/http-server
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if (argv.h || argv.help) {
'usage: http-server [path] [options]',
'',
'options:',
' -b Base path [/]',
' -p Port to use [8080]',
' -a Address to use [0.0.0.0]',
' -d Show directory listings [true]',
Expand Down Expand Up @@ -94,6 +95,7 @@ else {

function listen(port) {
var options = {
baseDir: argv.b,
root: argv._[0],
cache: argv.c,
showDir: argv.d,
Expand Down
2 changes: 2 additions & 0 deletions lib/http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function HttpServer(options) {

this.headers = options.headers || {};

this.baseDir = options.baseDir === undefined ? '/' : options.baseDir;
this.cache = options.cache === undefined ? 3600 : options.cache; // in seconds.
this.showDir = options.showDir !== 'false';
this.autoIndex = options.autoIndex !== 'false';
Expand Down Expand Up @@ -94,6 +95,7 @@ function HttpServer(options) {
}

before.push(ecstatic({
baseDir: this.baseDir,
root: this.root,
cache: this.cache,
showDir: this.showDir,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"dependencies": {
"colors": "1.0.3",
"corser": "~2.0.0",
"ecstatic": "^2.0.0",
"ecstatic": "^3.0.0",
"http-proxy": "^1.8.1",
"opener": "~1.4.0",
"optimist": "0.6.x",
Expand Down

0 comments on commit 6eeb679

Please sign in to comment.