aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/calculator.coffee
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2014-08-08 11:33:43 -0700
committerAdam Soltys <[email protected]>2014-08-08 11:33:43 -0700
commit2cc86381a6f79cd729048b34a72b70562a7b0ace (patch)
treec42dda997719ce544a4dea2bf15937d293ebfd59 /src/routes/calculator.coffee
parent3082e274b70a93fdac8a9a63934252ed914fe406 (diff)
parent6d5c3a56067b96bb5d97cca4a80bacbf78395b2c (diff)
downloadcoinos-server-2cc86381a6f79cd729048b34a72b70562a7b0ace.tar.gz
coinos-server-2cc86381a6f79cd729048b34a72b70562a7b0ace.zip
Merge branch 'code_reorg'
Diffstat (limited to 'src/routes/calculator.coffee')
-rw-r--r--src/routes/calculator.coffee27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/routes/calculator.coffee b/src/routes/calculator.coffee
new file mode 100644
index 00000000..4f3ac0b5
--- /dev/null
+++ b/src/routes/calculator.coffee
@@ -0,0 +1,27 @@
+exports.sweep = (req, res) ->
+ res.render('calculator/sweep',
+ layout: 'layout',
+ navigation: true,
+ js: (-> global.js),
+ css: (-> global.css)
+ )
+
+exports.ticker = (req, res) ->
+ fs = require('fs')
+ fs.readFile("./public/js/rates.json", (err, data) ->
+ req.query.currency ||= 'CAD'
+ req.query.symbol ||= 'quadrigacx'
+ req.query.type ||= 'bid'
+
+ try
+ exchange = JSON.parse(data)[req.query.currency][req.query.symbol]['rates'][req.query.type].toString()
+ catch e
+ exchange = "0"
+
+ res.writeHead(200,
+ 'Content-Length': exchange.length,
+ 'Content-Type': 'text/plain')
+ res.write(exchange)
+ res.end()
+ )
+