mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 10:07:08 +00:00
19 lines
651 B
JavaScript
19 lines
651 B
JavaScript
const compression = require('compression');
|
|
|
|
const compress = compression({
|
|
level: 6, // Balance speed vs. ratio (1-9)
|
|
threshold: 512, // Compress only if response >512 bytes to avoid overhead on small bundles
|
|
filter: (req, res) => { // Ensure bundles are compressed
|
|
const accept = req.get("Accept");
|
|
if (accept.startsWith("application/vnd.aaltronav.dougal+octet-stream")) return true;
|
|
if (accept.includes("json")) return true;
|
|
if (accept.startsWith("text/")) return true;
|
|
if (accept.startsWith("model/obj")) return true;
|
|
|
|
// fallback to standard filter function
|
|
return compression.filter(req, res)
|
|
}
|
|
});
|
|
|
|
module.exports = compress;
|