Support for request-ip

This commit is contained in:
Adam Babcock
2015-08-17 11:25:39 -05:00
parent 832c51db81
commit 232240bea5
2 changed files with 42 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
/// <reference path="../express/express.d.ts" />
/// <reference path="request-ip.d.ts" />
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();
};
+32
View File
@@ -0,0 +1,32 @@
// Type definitions for request-ip
// Project: https://github.com/pbojinov/request-ip
// Definitions by: Adam Babcock <https://github.com/mrhen>
// 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;
}