Skip to content

Commit

Permalink
Add short circuit if using cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Maros Hluska committed Aug 29, 2018
1 parent 304f922 commit f8bb8b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/express-http-server.js
Expand Up @@ -38,6 +38,16 @@ class ExpressHTTPServer {
app.use(require('compression')());
}

if (this.cache && this.gzip) {
app.use(function(req, res, next) {
if (res.body) {
res.send(res.body);
} else {
next();
}
});
}

if (username !== undefined || password !== undefined) {
this.ui.writeLine(`adding basic auth; username=${username}; password=${password}`);
app.use(basicAuth(username, password));
Expand Down
1 change: 1 addition & 0 deletions src/worker.js
Expand Up @@ -37,6 +37,7 @@ class Worker {
}

if (!this.httpServer.cache) { this.httpServer.cache = this.cache; }
if (!this.httpServer.gzip) { this.httpServer.gzip = this.gzip; }
if (!this.httpServer.distPath) { this.httpServer.distPath = this.distPath; }
if (!this.httpServer.ui) { this.httpServer.ui = this.ui; }
}
Expand Down

0 comments on commit f8bb8b9

Please sign in to comment.