File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed
Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,13 @@ app.use(
2020 flush : zlib . constants . Z_NO_FLUSH ,
2121 finishFlush : zlib . constants . Z_FINISH ,
2222 dictionary : Buffer . from ( "Hello World!" ) ,
23+ // brotli options
24+ brotli : {
25+ params : {
26+ [ zlib . constants . BROTLI_PARAM_QUALITY ] : 4 ,
27+ [ zlib . constants . BROTLI_PARAM_MODE ] : zlib . constants . BROTLI_DEFAULT_MODE ,
28+ } ,
29+ } ,
2330 info : true ,
2431 } ) ,
2532) ;
@@ -38,6 +45,8 @@ app.use(
3845 } ) ,
3946) ;
4047
48+ app . use ( compression ( { enforceEncoding : "br" } ) ) ;
49+
4150// compression.filter
4251
4352app . use ( compression ( { filter : shouldCompress } ) ) ;
Original file line number Diff line number Diff line change 11import express = require( "express" ) ;
2+ import * as zlib from "zlib" ;
23
34// This module adds a res.flush() method to force the partially-compressed response to be flushed to the client.
45
@@ -81,6 +82,17 @@ declare namespace compression {
8182 */
8283 filter ?: CompressionFilter | undefined ;
8384
85+ /**
86+ * Options for brotli compression.
87+ */
88+ brotli ?: zlib . BrotliOptions | undefined ;
89+
90+ /**
91+ * This is the default encoding to use when the client does not specify an encoding in the request's Accept-Encoding header.
92+ * @default 'identity'
93+ */
94+ enforceEncoding ?: string | undefined ;
95+
8496 /**
8597 * The level of zlib compression to apply to responses. A higher level will result in better compression, but
8698 * will take longer to complete. A lower level will result in less compression, but will be much faster.
Original file line number Diff line number Diff line change 11{
22 "private" : true ,
33 "name" : " @types/compression" ,
4- "version" : " 1.7 .9999" ,
4+ "version" : " 1.8 .9999" ,
55 "projects" : [
66 " https://github.com/expressjs/compression"
77 ],
88 "dependencies" : {
9- "@types/express" : " *"
9+ "@types/express" : " *" ,
10+ "@types/node" : " *"
1011 },
1112 "devDependencies" : {
12- "@types/compression" : " workspace:." ,
13- "@types/node" : " *"
13+ "@types/compression" : " workspace:."
1414 },
1515 "owners" : [
1616 {
You can’t perform that action at this time.
0 commit comments