Merge pull request #5403 from MrHen/feature/request-ip

Support for request-ip
This commit is contained in:
Masahiro Wakame
2015-08-21 21:10:30 +09:00
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;
}