diff options
| author | Adam Soltys <[email protected]> | 2012-11-07 11:50:43 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2012-11-07 11:50:43 -0800 |
| commit | 5a4e3ff9bf1db2db4fc5ae8d3bd7dcefc8c58e25 (patch) | |
| tree | 6fa4b507e859b92374b3114fe6073174efe0d10d /app.js | |
| parent | 22a115eade730e7c02a25bef35b45bbb1f1a63f0 (diff) | |
| download | coinos-server-5a4e3ff9bf1db2db4fc5ae8d3bd7dcefc8c58e25.tar.gz coinos-server-5a4e3ff9bf1db2db4fc5ae8d3bd7dcefc8c58e25.zip | |
Store and use commission rate, move DB connection info into separate file
Diffstat (limited to 'app.js')
| -rw-r--r-- | app.js | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -2,6 +2,7 @@ var express = require('express') , http = require('http') , path = require('path') , engines = require('consolidate') + , config = require('./config') , app = express(); app.engine('html', engines.hogan); @@ -17,10 +18,27 @@ app.get('/report', function(req, res) { res.render('report'); }); +app.get('/calculator', function(req, res) { + res.render('calculator'); +}); + +app.get('/client/:login', function(req, res) { + var connection = require('mysql').createConnection(config.database); + + connection.connect(); + connection.query("SELECT name, address, commission, logo FROM users WHERE login = ?", + [req.params.login], function(err, rows) { + res.write(JSON.stringify(rows)); + connection.end(); + res.end(); + } + ); +}); + app.get('/ticker', function(req, res) { var options = { host: 'bitcoincharts.com', - path: '/t/depthcalc.json?symbol=virtexCAD&type=bid&amount=1001¤cy=true' + path: '/t/depthcalc.json?symbol=virtexCAD&type=bid&amount=1000¤cy=true' } require('http').get(options, function(r) { @@ -32,7 +50,7 @@ app.get('/ticker', function(req, res) { }); app.get('/:client', function(req, res) { - res.render('calculator', { title: req.param('client') }); + res.render('calculator', { client: req.params.client }); }); app.listen(3000); |
