-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (31 loc) · 1.01 KB
/
index.js
File metadata and controls
31 lines (31 loc) · 1.01 KB
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
// Generated by LiveScript 1.5.0
(function(){
var express, cors, get, ref$, useProxy, proxyAddress, constantRateUsd, port, ip, tokenSymbol, proxy, constant, handler;
express = require('express');
cors = require('cors');
get = require('superagent').get;
ref$ = require('./config.json'), useProxy = ref$.useProxy, proxyAddress = ref$.proxyAddress, constantRateUsd = ref$.constantRateUsd, port = ref$.port, ip = ref$.ip, tokenSymbol = ref$.tokenSymbol;
proxy = function(req, res){
return get(proxyAddress).end(function(err, data){
if (err != null) {
return res.status(400).send(err + "");
}
return res.send(data.body);
});
};
constant = function(req, res){
var ref$;
return res.send((ref$ = {}, ref$[tokenSymbol + ""] = {
USD: constantRateUsd
}, ref$));
};
handler = (function(){
switch (false) {
case !useProxy:
return proxy;
default:
return constant;
}
}());
express().use(cors()).get('/rate', handler).listen(port, ip);
}).call(this);