mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
Support for request-ip
This commit is contained in:
@@ -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();
|
||||
};
|
||||
Vendored
+32
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user