Gathering detailed insights and metrics for koa-compress
Gathering detailed insights and metrics for koa-compress
Gathering detailed insights and metrics for koa-compress
Gathering detailed insights and metrics for koa-compress
npm install koa-compress
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
437 Stars
180 Commits
36 Forks
10 Watching
7 Branches
28 Contributors
Updated on 18 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-16.4%
60,780
Compared to previous day
Last week
-2.2%
356,049
Compared to previous week
Last month
10.4%
1,537,715
Compared to previous month
Last year
-17.6%
16,208,721
Compared to previous year
Compress middleware for Koa
1const compress = require('koa-compress') 2const Koa = require('koa') 3 4const app = new Koa() 5app.use(compress({ 6 filter (content_type) { 7 return /text/i.test(content_type) 8 }, 9 threshold: 2048, 10 gzip: { 11 flush: require('zlib').constants.Z_SYNC_FLUSH 12 }, 13 deflate: { 14 flush: require('zlib').constants.Z_SYNC_FLUSH, 15 }, 16 br: false // disable brotli 17}))
1function (mimeType: string): Boolean { 2 3}
An optional function that checks the response content type to decide whether to compress. By default, it uses compressible.
Minimum response size in bytes to compress.
Default 1024
bytes or 1kb
.
The current encodings are, in order of preference: br
, gzip
, deflate
.
Setting options[encoding] = {}
will pass those options to the encoding function.
Setting options[encoding] = false
will disable that encoding.
Brotli compression is supported in node v11.7.0+, which includes it natively. As of v5.1.0, the default quality level is 4 for performance reasons.
An optional string, which specifies what encoders to use for requests without
Accept-Encoding.
Default identity
.
The standard dictates to treat such requests as *
meaning that all compressions are permissible,
yet it causes very practical problems when debugging servers with manual tools like curl
, wget
, and so on.
If you want to enable the standard behavior, just set defaultEncoding
to *
.
You can always enable compression by setting ctx.compress = true
.
You can always disable compression by setting ctx.compress = false
.
This bypasses the filter check.
1app.use((ctx, next) => { 2 ctx.compress = true 3 ctx.body = fs.createReadStream(file) 4})
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 1/5 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More