File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ /// <reference path="../express/express.d.ts" />
2
+ /// <reference path="request-ip.d.ts" />
3
+
4
+ import express = require( 'express' ) ;
5
+ import requestIp = require( 'request-ip' ) ;
6
+
7
+ var ipMiddleware = function ( req :express . Request , res :express . Response , next :Function ) {
8
+ var clientIp = requestIp . getClientIp ( req ) ;
9
+ next ( ) ;
10
+ } ;
Original file line number Diff line number Diff line change
1
+ // Type definitions for request-ip
2
+ // Project: https://github.com/pbojinov/request-ip
3
+ // Definitions by: Adam Babcock <https://github.com/mrhen>
4
+ // Definitions: https://github.com/borisyankov/DefinitelyTyped
5
+
6
+ declare module "request-ip" {
7
+ interface Request {
8
+ headers : {
9
+ 'x-client-ip' ?: string ;
10
+ 'x-forwarded-for' ?: string ;
11
+ 'x-real-ip' ?: string ;
12
+ 'x-cluster-client-ip' ?: string ;
13
+ 'x-forwarded' ?: string ;
14
+ 'forwarded-for' ?: string ;
15
+ 'forwarded' ?: string ;
16
+ } ;
17
+ connection : {
18
+ remoteAddress ?: string ;
19
+ socket ?: {
20
+ remoteAddress ?: string
21
+ } ;
22
+ } ;
23
+ info ?: {
24
+ remoteAddress ?: string
25
+ } ;
26
+ socket ?: {
27
+ remoteAddress ?: string
28
+ } ;
29
+ }
30
+
31
+ export function getClientIp ( req :Request ) :string ;
32
+ }
You can’t perform that action at this time.
0 commit comments