mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Add new RequestEvents type.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import * as Podium from "podium";
|
||||
|
||||
/**
|
||||
* 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding).
|
||||
* 'finish' - emitted when the request payload finished reading. The event method signature is function ().
|
||||
* 'disconnect' - emitted when a request errors or aborts unexpectedly.
|
||||
* For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents)
|
||||
*/
|
||||
export type RequestEventType = "peek" | "finish" | "disconnect";
|
||||
|
||||
/**
|
||||
* Access: read only and the public podium interface.
|
||||
* The request.events supports the following events:
|
||||
* * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding).
|
||||
* * 'finish' - emitted when the request payload finished reading. The event method signature is function ().
|
||||
* * 'disconnect' - emitted when a request errors or aborts unexpectedly.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents)
|
||||
*/
|
||||
export interface RequestEvents extends Podium {
|
||||
|
||||
/**
|
||||
* Access: read only and the public podium interface.
|
||||
* The request.events supports the following events:
|
||||
* * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding).
|
||||
* * 'finish' - emitted when the request payload finished reading. The event method signature is function ().
|
||||
* * 'disconnect' - emitted when a request errors or aborts unexpectedly.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents)
|
||||
*/
|
||||
on(criteria: RequestEventType, listener: Function): void;
|
||||
|
||||
/**
|
||||
* Access: read only and the public podium interface.
|
||||
* The request.events supports the following events:
|
||||
* * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding).
|
||||
* * 'finish' - emitted when the request payload finished reading. The event method signature is function ().
|
||||
* * 'disconnect' - emitted when a request errors or aborts unexpectedly.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents)
|
||||
*/
|
||||
once(criteria: RequestEventType, listener: Function): void;
|
||||
|
||||
|
||||
|
||||
// TODO is it necessary to implement "emmit" event here?
|
||||
|
||||
}
|
||||
+2
-1
@@ -9,6 +9,7 @@ import {RequestRoute} from "./request-route";
|
||||
import {RequestAuth} from "./request-auth";
|
||||
import {RequestInfo} from "./request-info";
|
||||
import * as Podium from "podium";
|
||||
import {RequestEvents} from "hapi";
|
||||
|
||||
/**
|
||||
* TODO both objects ReplyValue and _ReplyValue I found in the v16 TS definition, but I don't found it in the documentation. Need review.
|
||||
@@ -61,7 +62,7 @@ export interface Request extends Podium {
|
||||
* * 'disconnect' - emitted when a request errors or aborts unexpectedly.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents)
|
||||
*/
|
||||
events: 'peek' | 'finish' | 'disconnect'; // TODO I think it's wrong. Maybe is events.on(' ', ' '). It needs revision.
|
||||
events: RequestEvents;
|
||||
|
||||
/**
|
||||
* The raw request headers (references request.raw.req.headers).
|
||||
|
||||
Reference in New Issue
Block a user