Skip to content

Commit

Permalink
Merge pull request #62 from VikramTiwari/update-deps
Browse files Browse the repository at this point in the history
Update deps and make the library lean
  • Loading branch information
VikramTiwari authored Jan 30, 2021
2 parents a3d8390 + 9bb0e20 commit de0cf4f
Show file tree
Hide file tree
Showing 7 changed files with 1,106 additions and 748 deletions.
29 changes: 14 additions & 15 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@ on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x]
node-version: [12.x, 14.x, 15.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm ci
npm run build --if-present
npm test
env:
CI: true
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm ci
npm run build --if-present
npm test
env:
CI: true
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
46 changes: 32 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,39 @@ yarn add --save geo-from-ip
```javascript
const geoip = require('geo-from-ip')
console.log(geoip.allData('199.188.195.120'))
```

/*
{ code: { state: 'CA', country: 'US', continent: 'NA' },
city: 'San Francisco',
state: 'California',
country: 'United States',
continent: 'North America',
postal: '94103',
location:
{ accuracy_radius: 10,
latitude: 37.7758,
longitude: -122.4128,
metro_code: 807,
time_zone: 'America/Los_Angeles' } }
*/
- And the complete response will be returned

```json
{
"code": {
"state": "CA",
"country": "US",
"registeredCountry": "US",
"continent": "NA"
},
"geonameId": {
"city": 5391959,
"state": 5332921,
"country": 6252001,
"registeredCountry": 6252001,
"continent": 6255149
},
"city": "San Francisco",
"state": "California",
"country": "United States",
"registeredCountry": "United States",
"continent": "North America",
"postal": "94107",
"location": {
"accuracy_radius": 5,
"latitude": 37.7642,
"longitude": -122.3993,
"metro_code": 807,
"time_zone": "America/Los_Angeles"
}
}
```

- Update database
Expand Down
273 changes: 273 additions & 0 deletions __tests__/__snapshots__/geo-from-ip.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`geo-from-ip allData 1.1.1.1 1`] = `
Object {
"city": null,
"code": Object {
"continent": "OC",
"country": "AU",
"registeredCountry": "AU",
"state": null,
},
"continent": "Oceania",
"country": "Australia",
"geonameId": Object {
"city": null,
"continent": 6255151,
"country": 2077456,
"registeredCountry": 2077456,
"state": null,
},
"location": Object {
"accuracy_radius": 1000,
"latitude": -33.494,
"longitude": 143.2104,
"time_zone": "Australia/Sydney",
},
"registeredCountry": "Australia",
"state": null,
}
`;

exports[`geo-from-ip allData 8.8.8.8 1`] = `
Object {
"city": null,
"code": Object {
"continent": "NA",
"country": "US",
"registeredCountry": "US",
"state": null,
},
"continent": "North America",
"country": "United States",
"geonameId": Object {
"city": null,
"continent": 6255149,
"country": 6252001,
"registeredCountry": 6252001,
"state": null,
},
"location": Object {
"accuracy_radius": 1000,
"latitude": 37.751,
"longitude": -97.822,
"time_zone": "America/Chicago",
},
"registeredCountry": "United States",
"state": null,
}
`;

exports[`geo-from-ip allData 18.12.25.208 1`] = `
Object {
"city": "Cambridge",
"code": Object {
"continent": "NA",
"country": "US",
"registeredCountry": "US",
"state": "MA",
},
"continent": "North America",
"country": "United States",
"geonameId": Object {
"city": 4931972,
"continent": 6255149,
"country": 6252001,
"registeredCountry": 6252001,
"state": 6254926,
},
"location": Object {
"accuracy_radius": 1000,
"latitude": 42.3649,
"longitude": -71.0987,
"metro_code": 506,
"time_zone": "America/New_York",
},
"postal": "02139",
"registeredCountry": "United States",
"state": "Massachusetts",
}
`;

exports[`geo-from-ip allData 53.251.2.108 1`] = `
Object {
"city": null,
"code": Object {
"continent": "EU",
"country": "DE",
"registeredCountry": "DE",
"state": null,
},
"continent": "Europe",
"country": "Germany",
"geonameId": Object {
"city": null,
"continent": 6255148,
"country": 2921044,
"registeredCountry": 2921044,
"state": null,
},
"location": Object {
"accuracy_radius": 200,
"latitude": 51.2993,
"longitude": 9.491,
"time_zone": "Europe/Berlin",
},
"registeredCountry": "Germany",
"state": null,
}
`;

exports[`geo-from-ip allData 95.84.136.77 1`] = `
Object {
"city": "Moscow",
"code": Object {
"continent": "EU",
"country": "RU",
"registeredCountry": "RU",
"state": "MOW",
},
"continent": "Europe",
"country": "Russia",
"geonameId": Object {
"city": 524901,
"continent": 6255148,
"country": 2017370,
"registeredCountry": 2017370,
"state": 524894,
},
"location": Object {
"accuracy_radius": 1,
"latitude": 55.7482,
"longitude": 37.6177,
"time_zone": "Europe/Moscow",
},
"postal": "102289",
"registeredCountry": "Russia",
"state": "Moscow",
}
`;

exports[`geo-from-ip allData 199.188.195.120 1`] = `
Object {
"city": "San Francisco",
"code": Object {
"continent": "NA",
"country": "US",
"registeredCountry": "US",
"state": "CA",
},
"continent": "North America",
"country": "United States",
"geonameId": Object {
"city": 5391959,
"continent": 6255149,
"country": 6252001,
"registeredCountry": 6252001,
"state": 5332921,
},
"location": Object {
"accuracy_radius": 5,
"latitude": 37.7642,
"longitude": -122.3993,
"metro_code": 807,
"time_zone": "America/Los_Angeles",
},
"postal": "94107",
"registeredCountry": "United States",
"state": "California",
}
`;

exports[`geo-from-ip allData 223.63.194.232 1`] = `
Object {
"city": "Busan",
"code": Object {
"continent": "AS",
"country": "KR",
"registeredCountry": "KR",
"state": "26",
},
"continent": "Asia",
"country": "South Korea",
"geonameId": Object {
"city": 1838524,
"continent": 6255147,
"country": 1835841,
"registeredCountry": 1835841,
"state": 1838519,
},
"location": Object {
"accuracy_radius": 100,
"latitude": 35.1003,
"longitude": 129.0442,
"time_zone": "Asia/Seoul",
},
"postal": "48943",
"registeredCountry": "South Korea",
"state": "Busan",
}
`;

exports[`geo-from-ip error 0 1`] = `
Object {
"code": Object {},
"error": "NA",
"geonameId": Object {},
"ip": "0",
}
`;

exports[`geo-from-ip error 0.0.0.0 1`] = `
Object {
"code": Object {},
"error": "NA",
"geonameId": Object {},
"ip": "0.0.0.0",
}
`;

exports[`geo-from-ip error 10.0.0.1 1`] = `
Object {
"code": Object {},
"error": "NA",
"geonameId": Object {},
"ip": "10.0.0.1",
}
`;

exports[`geo-from-ip error 127.0.0.1 1`] = `
Object {
"code": Object {},
"error": "NA",
"geonameId": Object {},
"ip": "127.0.0.1",
}
`;

exports[`geo-from-ip error 172.16.0.1 1`] = `
Object {
"code": Object {},
"error": "NA",
"geonameId": Object {},
"ip": "172.16.0.1",
}
`;

exports[`geo-from-ip error 192.168.0.1 1`] = `
Object {
"code": Object {},
"error": "NA",
"geonameId": Object {},
"ip": "192.168.0.1",
}
`;

exports[`geo-from-ip error 255.255.255.255 1`] = `
Object {
"code": Object {},
"error": "NA",
"geonameId": Object {},
"ip": "255.255.255.255",
}
`;
Loading

0 comments on commit de0cf4f

Please sign in to comment.