Fix MiddlewareFunction interface

1. Change client request/response to server request/response, because
the client ones are for when node is acting as a client (making
outgoing requests), whereas here it’s acting as a server. This change
is needed to work with express.

2. Change the `next` argument, because next (in express) is a function
called with 0 or 1 arguments, where that argument can be an any (for
the error). Next is decidedly *not* a function with the
MiddlewareFunction signature.

3. Import express with a capital E, for consistency with Http, since
we’re using it for its namespace.
This commit is contained in:
Ethan Resnick
2016-09-19 18:58:03 -04:00
parent d705c4e9da
commit 6164f95bb1

6
twilio/twilio.d.ts vendored
View File

@@ -7,7 +7,7 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="../q/Q.d.ts" />
import * as express from 'express';
import * as Express from 'express';
import * as Http from 'http';
import q = require('q');
@@ -444,13 +444,13 @@ declare namespace twilio {
}
// For interop with node middleware chains
export interface MiddlewareFunction { (request: Http.ClientRequest, response: Http.ClientResponse, next: MiddlewareFunction): void; }
export interface MiddlewareFunction { (request: Http.ServerRequest, response: Http.ServerResponse, next: Express.NextFunction): void; }
export function webhook(authToken: string, options?: webhookOptions): MiddlewareFunction;
export function webhook(options?: webhookOptions): MiddlewareFunction;
export function validateRequest(authToken: string, twilioHeader: string, url: string, params?: any): boolean;
export function validateExpressRequest(request: express.Request, authToken: string, options?: WebhookExpressOptions): boolean;
export function validateExpressRequest(request: Express.Request, authToken: string, options?: WebhookExpressOptions): boolean;
/// resources/Accounts.js
export interface OutgoingCallerIdInstance extends InstanceResource {