0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Enable caching of static assets (#1217)

* Enable caching of static assets

* Remove dependency on mime package

Since we only care about two file extensions at the moment,
there is no need to grab the whole package just to avoid
calling 'endsWith' twice.
This commit is contained in:
Alexey Sachkov
2021-02-20 01:58:02 +03:00
committed by GitHub
parent ecae16b5d4
commit 7057422077
3 changed files with 39 additions and 13 deletions

View File

@@ -1,18 +1,13 @@
const _ = require('lodash');
const jwt = require('jwt-simple');
const expressStaticGzip = require('express-static-gzip');
const express = require('express');
const app = express();
const homebrewApi = require('./server/homebrew.api.js');
const GoogleActions = require('./server/googleActions.js');
const serveCompressedStaticAssets = require('./server/static-assets.mv.js');
// Serve brotli-compressed static files if available
app.use('/', expressStaticGzip(`${__dirname}/build`, {
enableBrotli : true,
orderPreference : ['br'],
index : false
}));
app.use('/', serveCompressedStaticAssets(`${__dirname}/build`));
process.chdir(__dirname);