Skip to content

Commit

Permalink
Replaced iplocation package with node-iplocate
Browse files Browse the repository at this point in the history
  • Loading branch information
omgimanerd committed Mar 1, 2019
1 parent 8b100e3 commit ab43288
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 20 deletions.
58 changes: 42 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"colors": "^1.1.2", "colors": "^1.1.2",
"express": "^4.16.4", "express": "^4.16.4",
"express-winston": "^2.6.0", "express-winston": "^2.6.0",
"iplocation": "^6.1.0",
"moment": "^2.18.1", "moment": "^2.18.1",
"moment-timezone": "^0.5.23", "moment-timezone": "^0.5.23",
"mongodb": "^3.1.13", "mongodb": "^3.1.13",
"nanoid": "^2.0.1", "nanoid": "^2.0.1",
"newsapi": "^2.4.0", "newsapi": "^2.4.0",
"node-iplocate": "^1.0.1",
"winston": "^2.4.4" "winston": "^2.4.4"
}, },
"devDependencies": { "devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions server.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const INTERNAL_ERROR = '\nAn error occurred! Please try again in a bit.\n'
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const colors = require('colors') const colors = require('colors')
const express = require('express') const express = require('express')
const iplocation = require('iplocation').default
const moment = require('moment-timezone') const moment = require('moment-timezone')
const mongodb = require('mongodb') const mongodb = require('mongodb')
const iplocate = require('node-iplocate')
const newsapi = require('newsapi') const newsapi = require('newsapi')
const path = require('path') const path = require('path')


Expand Down Expand Up @@ -81,8 +81,8 @@ app.get('/:query', async(request, response) => {
articles.forEach((article, i) => { article.url = shortenedUrls[i] }) articles.forEach((article, i) => { article.url = shortenedUrls[i] })
let timezone = null let timezone = null
try { try {
const locationData = await iplocation(request.headers['x-forwarded-for']) const locationData = await iplocate(request.headers['x-forwarded-for'])
timezone = locationData.timezone timezone = locationData.time_zone
} catch (error) { } catch (error) {
timezone = moment.tz.guess() timezone = moment.tz.guess()
} }
Expand Down

0 comments on commit ab43288

Please sign in to comment.