From 04151271c84112e672f07d6c3f9942de6eb5d579 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Fri, 2 Jun 2017 21:32:21 +1000 Subject: [PATCH] Add helpers to return geoinfo --- index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index fc65c18..dae36e2 100644 --- a/index.ts +++ b/index.ts @@ -13,7 +13,16 @@ app.set('view engine', 'handlebars'); app.get('/', function (req, res) { getIpInfo("::ffff:" + "119.17.156.106").done(function (geoinfo: IPGeoJson) { - res.render('home'); + res.render('home', { + helpers: { + ip: function() { return geoinfo.ip; }, + city: function() { return geoinfo.city; }, + region: function() {return geoinfo.region; }, + country: function() { return geoinfo.country; }, + loc: function() { return geoinfo.loc; }, + postal: function() { return geoinfo.postal } + } + }); }); //replace with req.ip });