mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #24287 from rburgt/master
compression - added missing default filter method interface
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
import express = require('express');
|
||||
import compress = require('compression');
|
||||
|
||||
@@ -7,3 +6,15 @@ app.use(compress());
|
||||
app.use(compress({
|
||||
threshold: 512
|
||||
}));
|
||||
app.use(compress({
|
||||
threshold: 512,
|
||||
filter: (req, res) => {
|
||||
if (req.headers['x-no-compression']) {
|
||||
// don't compress responses with this request header
|
||||
return false;
|
||||
}
|
||||
|
||||
// fallback to standard filter function
|
||||
return compress.filter(req, res);
|
||||
}
|
||||
}));
|
||||
Vendored
+17
-5
@@ -1,13 +1,26 @@
|
||||
// Type definitions for compression
|
||||
// Project: https://github.com/expressjs/compression
|
||||
// Definitions by: Santi Albo <https://github.com/santialbo>
|
||||
// Rob van der Burgt <https://github.com/rburgt>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import * as express from 'express';
|
||||
|
||||
declare function e(options?: e.CompressionOptions): express.RequestHandler;
|
||||
|
||||
declare namespace e {
|
||||
interface CompressionOptions {
|
||||
/**
|
||||
* Default filter, used for extending filter given in CompressionOptions
|
||||
* See https://github.com/expressjs/compression#filter-1 regarding the usage
|
||||
*/
|
||||
export function filter(req: express.Request, res: express.Response): boolean;
|
||||
|
||||
interface CompressionFilter {
|
||||
(req: express.Request, res: express.Response): boolean;
|
||||
}
|
||||
|
||||
interface CompressionOptions {
|
||||
/**
|
||||
* See https://github.com/expressjs/compression#chunksize regarding the usage.
|
||||
*/
|
||||
@@ -31,7 +44,7 @@ declare namespace e {
|
||||
/**
|
||||
* See https://github.com/expressjs/compression#threshold regarding the usage.
|
||||
*/
|
||||
threshold?: number|string;
|
||||
threshold?: number | string;
|
||||
|
||||
/**
|
||||
* See https://github.com/expressjs/compression#windowbits regarding the usage.
|
||||
@@ -41,8 +54,8 @@ declare namespace e {
|
||||
/**
|
||||
* See https://github.com/expressjs/compression#filter regarding the usage.
|
||||
*/
|
||||
filter?: Function;
|
||||
|
||||
filter?: CompressionFilter;
|
||||
|
||||
/**
|
||||
* See https://nodejs.org/api/zlib.html#zlib_class_options regarding the usage.
|
||||
*/
|
||||
@@ -55,5 +68,4 @@ declare namespace e {
|
||||
}
|
||||
}
|
||||
|
||||
declare function e(options?: e.CompressionOptions): express.RequestHandler;
|
||||
export = e;
|
||||
|
||||
Reference in New Issue
Block a user