constructor( private readonly configService: ConfigService, private readonly logger: MyLoggerService, ) { this.compression = compression(); }
this[kBundlers] = enableWatchify ? [testBundler, clientBundler] : [] this[kApp] = express() this[kApp].use(compression())
app.use(compression());
server.use(compression()); server.use(express.json());
app.prepare().then(() => { const server = express(); server.use(compression({ threshold: 0 })); server.use( cors({
app.use(compression()); app.use(bodyParser.json());
/* Compression -----------------------------------------------*/ app.use(compression({ filter: function(req, res){ return req.headers["x-no-compression"] ? false : compression.filter(req, res); } }));
// Production middlewares const addProdMiddlewares = (app, options) => { const publicPath = options.publicPath || '/'; const outputPath = options.outputPath || path.resolve(process.cwd(), 'build'); // compression middleware compresses your server responses which makes them // smaller (applies also to assets). You can read more about that technique // and other good practices on official Express.js docs http://mxs.is/googmy app.use(compression()); app.use(publicPath, express.static(outputPath)); app.get('*', (req, res) => res.sendFile(path.resolve(outputPath, 'index.html'))); }
app.use(compress({ filter: function(req, res) { return (/json|text|javascript|css|font|svg/).test(res.getHeader('Content-Type')); }, level: 9 }));
server.use(compression()); server.use(express.json());
// Should be placed before express.static app.use(compress({ filter: function(req, res) { return (/json|text|javascript|css/).test(res.getHeader('Content-Type')); }, level: 9 }));
// Should be placed before express.static app.use(compress({ filter: function(req, res) { return (/json|text|javascript|css|font|svg/).test(res.getHeader('Content-Type')); }, level: 9 }));
// Should be placed before express.static app.use(compress({ filter: function (req, res) { return (/json|text|javascript|css|font|svg/).test(res.getHeader('Content-Type')); }, level: 9 }));
// Should be placed before express.static app.use(compress({ filter: function (req, res) { return (/json|text|javascript|css|font|svg/).test(res.getHeader('Content-Type')); }, level: 9 }));
// Production middlewares const addProdMiddlewares = (app, options) => { const publicPath = options.publicPath || '/'; const outputPath = options.outputPath || path.resolve(process.cwd(), 'build'); // compression middleware compresses your server responses which makes them // smaller (applies also to assets). You can read more about that technique // and other good practices on official Express.js docs http://mxs.is/googmy app.use(compression()); app.use(publicPath, express.static(outputPath)); app.get('*', (req, res) => res.sendFile(path.resolve(outputPath, 'index.html'))); }