diff options
| author | Adam Soltys <[email protected]> | 2012-11-13 20:01:18 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2012-11-13 20:01:18 -0800 |
| commit | bb5a18653075ed57e89ce1965eccd8893d9e6458 (patch) | |
| tree | cd548dce3d3bd02aeec734c3b9323c30774fb761 | |
| parent | 16062edf148ea44bc8a5f40732c0dc1d363d588c (diff) | |
| download | coinos-server-bb5a18653075ed57e89ce1965eccd8893d9e6458.tar.gz coinos-server-bb5a18653075ed57e89ce1965eccd8893d9e6458.zip | |
Timeout if exchange can't be fetched
| -rw-r--r-- | app.coffee | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1,4 +1,3 @@ - express = require('express') http = require('http') path = require('path') @@ -55,6 +54,11 @@ app.get('/:user/transactions', (req, res) -> app.get('/ticker', (req, res) -> + t = setTimeout(-> + res.writeHead(500, {'Content-Type': 'text/plain'}) + res.end() + , 2000) + options = host: 'bitcoincharts.com', path: '/t/depthcalc.json?symbol=' + req.query.symbol + '&type=bid&amount=1000¤cy=true' @@ -62,8 +66,10 @@ app.get('/ticker', (req, res) -> require('http').get(options, (r) -> r.setEncoding('utf-8') r.on('data', (chunk) -> + clearTimeout(t) res.send(chunk) - ) + res.end() + ) ) ) |
