aboutsummaryrefslogtreecommitdiffstats
path: root/routes/calculator.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2014-07-20 11:24:09 -0700
committerAdam Soltys <[email protected]>2014-07-20 11:40:36 -0700
commit51daca704f27e59462c6d8b1731867007c8fd273 (patch)
treee573e97c4704710ff1fd8dbd5ff033504847890a /routes/calculator.js
parent9b8d66d8a7c9417132358ac2b0f0dbfa4fcd9fcd (diff)
downloadcoinos-server-51daca704f27e59462c6d8b1731867007c8fd273.tar.gz
coinos-server-51daca704f27e59462c6d8b1731867007c8fd273.zip
Precompile all coffeescript
Diffstat (limited to 'routes/calculator.js')
-rw-r--r--routes/calculator.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/routes/calculator.js b/routes/calculator.js
new file mode 100644
index 00000000..834d9bbc
--- /dev/null
+++ b/routes/calculator.js
@@ -0,0 +1,41 @@
+(function() {
+ exports["new"] = function(req, res) {
+ return res.render('calculator/setup');
+ };
+
+ exports.sweep = function(req, res) {
+ return res.render('calculator/sweep', {
+ layout: 'layout'
+ });
+ };
+
+ exports.show = function(req, res) {
+ return res.render('calculator/show', {
+ layout: 'layout'
+ });
+ };
+
+ exports.ticker = function(req, res) {
+ var fs;
+ fs = require('fs');
+ return fs.readFile("./public/js/rates.json", function(err, data) {
+ var e, exchange, _base, _base1, _base2;
+ (_base = req.query).currency || (_base.currency = 'CAD');
+ (_base1 = req.query).symbol || (_base1.symbol = 'quadrigacx');
+ (_base2 = req.query).type || (_base2.type = 'bid');
+ try {
+ exchange = JSON.parse(data)[req.query.currency][req.query.symbol]['rates'][req.query.type].toString();
+ } catch (_error) {
+ e = _error;
+ exchange = "0";
+ }
+ res.writeHead(200, {
+ 'Content-Length': exchange.length,
+ 'Content-Type': 'text/plain'
+ });
+ res.write(exchange);
+ return res.end();
+ });
+ };
+
+}).call(this);