-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.es5.js
34 lines (25 loc) · 886 Bytes
/
server.es5.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
var _express = require('express');
var _express2 = _interopRequireDefault(_express);
var _request = require('request');
var _request2 = _interopRequireDefault(_request);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var app = (0, _express2.default)();
app.get('/model.json', function (req, res) {
var params = {
username: process.env.GEO_USERNAME,
maxRows: 5,
q: req.query.q
};
var GEO_URL = 'http://api.geonames.org/searchJSON';
(0, _request2.default)({ url: GEO_URL, qs: params }, function (error, response, body) {
if (error) {
// TODO: send down the error so the UI can reflect it
return console.log(error);
}
// TODO: send just what we need
res.send(JSON.parse(body));
});
});
app.use(_express2.default.static('dist'));
app.listen(process.env.PORT || 3000);