File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ /// <reference path="geoip-lite.d.ts"/>
2
+
3
+ // require geoip-lite
4
+ import geoip = require( 'geoip-lite' ) ;
5
+
6
+ // lookup an IP addres
7
+ var geo = geoip . lookup ( '199.16.156.125' ) ;
8
+
9
+ // convert the ip block range to string
10
+ if ( geo ) {
11
+ let rangeStart = geoip . pretty ( geo . range [ 0 ] ) ;
12
+ let rangeEnd = geoip . pretty ( geo . range [ 1 ] ) ;
13
+ }
14
+
15
+ // start the data update watcher
16
+ geoip . startWatchingDataUpdate ( ) ;
17
+
18
+ // stop the data update watcher
19
+ geoip . stopWatchingDataUpdate ( ) ;
Original file line number Diff line number Diff line change
1
+ // Type definitions for GeoIP-lite 1.1.6
2
+ // Project: https://github.com/bluesmoon/node-geoip
3
+ // Definitions by: Yuce Tekol <http://yuce.me/>
4
+ // Definitions: https://github.com/borisyankov/DefinitelyTyped
5
+
6
+ declare module 'geoip-lite' {
7
+ module mod {
8
+ export interface Lookup {
9
+ range : Array < number > ; // range start, end
10
+ country : string ;
11
+ region : string ;
12
+ city : string ;
13
+ ll : Array < number > ; // latitude, longitude
14
+ }
15
+
16
+ export function lookup ( ip : string ) : Lookup ;
17
+ export function pretty ( ip : number ) : string ;
18
+ export function startWatchingDataUpdate ( ) : void ;
19
+ export function stopWatchingDataUpdate ( ) : void ;
20
+ }
21
+ export = mod ;
22
+ }
You can’t perform that action at this time.
0 commit comments