mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
feat(hijackresponse): new type definition (#47540)
This commit is contained in:
parent
84fd109a44
commit
4851ad40fb
15
types/hijackresponse/hijackresponse-tests.ts
Normal file
15
types/hijackresponse/hijackresponse-tests.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import * as express from 'express';
|
||||
import * as hijackResponse from 'hijackresponse';
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use((req, res, next) => {
|
||||
hijackResponse(res, (err, res) => {
|
||||
res.setHeader("X-Hijacked", "yes!");
|
||||
res.removeHeader("Content-Length");
|
||||
|
||||
res.pipe(res);
|
||||
});
|
||||
|
||||
next();
|
||||
});
|
||||
23
types/hijackresponse/index.d.ts
vendored
Normal file
23
types/hijackresponse/index.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Type definitions for hijackresponse 4.0
|
||||
// Project: https://github.com/gustavnikolaj/hijackresponse
|
||||
// Definitions by: Matthias Kunnen <https://github.com/MatthiasKunnen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// Minimum TypeScript Version: 3.5
|
||||
|
||||
import express = require('express');
|
||||
import { Readable } from 'stream';
|
||||
|
||||
declare namespace e {
|
||||
interface HijackedResponse<ResBody = any>
|
||||
extends express.Response<ResBody>,
|
||||
Omit<Readable, keyof express.Response> {
|
||||
destroyHijacked: () => boolean;
|
||||
unhijack: () => express.Response;
|
||||
}
|
||||
}
|
||||
|
||||
declare function e<ResBody = any>(
|
||||
res: express.Response<ResBody>,
|
||||
callback: (err: null, res: e.HijackedResponse<ResBody>) => void,
|
||||
): void;
|
||||
export = e;
|
||||
23
types/hijackresponse/tsconfig.json
Normal file
23
types/hijackresponse/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hijackresponse-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/hijackresponse/tslint.json
Normal file
1
types/hijackresponse/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user