diff --git a/request-ip/request-ip-tests.ts b/request-ip/request-ip-tests.ts new file mode 100644 index 000000000..8c5111e33 --- /dev/null +++ b/request-ip/request-ip-tests.ts @@ -0,0 +1,10 @@ +/// +/// + +import express = require('express'); +import requestIp = require('request-ip'); + +var ipMiddleware = function(req:express.Request, res:express.Response, next:Function) { + var clientIp = requestIp.getClientIp(req); + next(); +}; diff --git a/request-ip/request-ip.d.ts b/request-ip/request-ip.d.ts new file mode 100644 index 000000000..e71ed1a37 --- /dev/null +++ b/request-ip/request-ip.d.ts @@ -0,0 +1,32 @@ +// Type definitions for request-ip +// Project: https://github.com/pbojinov/request-ip +// Definitions by: Adam Babcock +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "request-ip" { + interface Request { + headers: { + 'x-client-ip'?: string; + 'x-forwarded-for'?: string; + 'x-real-ip'?: string; + 'x-cluster-client-ip'?: string; + 'x-forwarded'?: string; + 'forwarded-for'?: string; + 'forwarded'?: string; + }; + connection: { + remoteAddress?: string; + socket?: { + remoteAddress?: string + }; + }; + info?: { + remoteAddress?: string + }; + socket?: { + remoteAddress?: string + }; + } + + export function getClientIp(req:Request):string; +}