Add compression to some endpoints.

Consideration will be given to adding (conditional) compression
to all endpoints.
This commit is contained in:
D. Berge
2025-08-11 01:53:50 +02:00
parent 2a7b51b995
commit aabcc74891
5 changed files with 84 additions and 81 deletions

View File

@@ -0,0 +1,16 @@
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
if (req.get("Accept") == "application/vnd.aaltronav.dougal+octet-stream") {
return true;
}
// fallback to standard filter function
return compression.filter(req, res)
}
});
module.exports = compress;