mirror of
https://github.com/italicsjenga/handlebars-ipinfo.git
synced 2024-11-24 05:21:29 +11:00
Add debugging
This commit is contained in:
parent
c8d88b2f5b
commit
8a86435408
3
index.ts
3
index.ts
|
@ -16,6 +16,7 @@ app.enable('trust-proxy');
|
||||||
|
|
||||||
app.get('/', function (req, res) {
|
app.get('/', function (req, res) {
|
||||||
getIpInfo(req.ip).done(function (geoinfo: IPGeoJson) {
|
getIpInfo(req.ip).done(function (geoinfo: IPGeoJson) {
|
||||||
|
console.log("ip: " + geoinfo.ip);
|
||||||
res.render('home', {
|
res.render('home', {
|
||||||
helpers: {
|
helpers: {
|
||||||
ip: function () { return geoinfo.ip; },
|
ip: function () { return geoinfo.ip; },
|
||||||
|
@ -59,8 +60,10 @@ function getIpInfo(ip: String): Promise.IThenable<{}> {
|
||||||
|
|
||||||
var cached = cache.get(ip);
|
var cached = cache.get(ip);
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
|
console.log("serving cached");
|
||||||
resolve(cached);
|
resolve(cached);
|
||||||
} else {
|
} else {
|
||||||
|
console.log("serving fetched");
|
||||||
https.get(options, callback);
|
https.get(options, callback);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue