old-silvrgit/lib/fx.min.js

3 lines
673 B
JavaScript
Raw Permalink Normal View History

2015-08-04 14:07:01 +00:00
var http=require("http"),fxCache={};exports.doFx=function(e,o){function n(e,o){var n={host:"openexchangerates.org",path:"/api/latest.json?app_id=0eb932cee3bc40259f824d4b4c96c7d2",headers:{}};http.request(n).on("response",function(n){var r="";n.on("data",function(e){r+=e}),n.on("end",function(){e(JSON.parse(r),o)})}).end()}console.log("FX request");var r=new Date;r-GLOBAL.lastcheck>84e4?n(function(e){console.log(e),fxCache=e,GLOBAL.lastcheck=r,o.setHeader("Content-Type","application/json"),o.end(JSON.stringify(fxCache))},o):(console.log("Using cache"),o.setHeader("Content-Type","application/json"),o.end(JSON.stringify(fxCache)))};
//# sourceMappingURL=fx.min.js.map