Skip to content

This is a simple middleware for an express App that gets the locations of every request thats hits the server. I am using freegeoip.net . Its free service it lets you hit 10000 requests per hour for ip's location.

License

Rohail1/iplocate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iplocate

CircleCI npm version
This is a simple middleware for an express App that gets the locations of every request thats hits the server. I am using freegeoip.net . Its free service it lets you hit 10000 requests per hour for ip's location.

##Installation

npm install iplocate --save

How to use

    let iplocate = require('iplocate');
    
    app.use(iplocate);

        
    router.get('api/route',function(req,res){
      if(req.locationError){
        // In case of Any error locationError will be populated
        console.log('req.locationError ',req.locationError)
      }else {
        // The location object will be attached to request
        console.log('req.location',req.location)
      }
    });
    
    // Or use it with APP
    
    app.get('api/route',function(req,res){
      if(req.locationError){
        // In case of Any error locationError will be populated
        console.log('req.locationError ',req.locationError)
      }else {
        // The location object will be attached to request
        console.log('req.location',req.location)
      }
    })    

###Tests

npm test

###Issues

Create an issue if there are any bugs.

For Any Queries

Feel free to contact me via email or on my website lumous.pk

About

This is a simple middleware for an express App that gets the locations of every request thats hits the server. I am using freegeoip.net . Its free service it lets you hit 10000 requests per hour for ip's location.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published