aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/calculator.coffee
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2014-07-31 21:06:23 -0700
committerAdam Soltys <[email protected]>2014-07-31 21:06:23 -0700
commit7c5dfc8d51efe4df4e67f86f33c489a320fcb8f9 (patch)
treef387c3d4e3ce9ed0c464659a787b99d8c6e90fb9 /src/routes/calculator.coffee
parentde1cdd2e3f9d9f36ce3d8e97335341cc3237e829 (diff)
downloadcoinos-server-7c5dfc8d51efe4df4e67f86f33c489a320fcb8f9.tar.gz
coinos-server-7c5dfc8d51efe4df4e67f86f33c489a320fcb8f9.zip
Move coffee files to src/ folder
Diffstat (limited to 'src/routes/calculator.coffee')
-rw-r--r--src/routes/calculator.coffee28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/routes/calculator.coffee b/src/routes/calculator.coffee
new file mode 100644
index 00000000..891fdce8
--- /dev/null
+++ b/src/routes/calculator.coffee
@@ -0,0 +1,28 @@
+exports.new = (req, res) ->
+ res.render('calculator/setup')
+
+exports.sweep = (req, res) ->
+ res.render('calculator/sweep', layout: 'layout')
+
+exports.show = (req, res) ->
+ res.render('calculator/show', layout: 'layout', x: 'meow')
+
+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()
+ )
+