Skip to content

Instantly share code, notes, and snippets.

@maxant
Last active August 29, 2015 14:12
Show Gist options
  • Save maxant/605c94552a5ece6701ad to your computer and use it in GitHub Desktop.
Save maxant/605c94552a5ece6701ad to your computer and use it in GitHub Desktop.
Web Server parts of trading-engine-parent3
logger.info('setting up HTTP server for receiving commands');
var express = require('express')
var app = express()
var id = 0;
app.get('/buy', function (req, res) {
logger.info(id + ') buying "' + req.query.quantity + '" of "' + req.query.productId + '"');
...
});
app.get('/sell', function (req, res) {
logger.info(id + ') selling "' + req.query.quantity + '" of "' + req.query.productId + '" at price "' + req.query.price + '"');
...
});
app.get('/result', function (req, res) {
var key = parseInt(req.query.id);
var r = results.get(key);
if(r){
results.delete(key);
res.json(r);
}else{
res.json({msg: 'UNKNOWN OR PENDING'});
}
});
var server = app.listen(3000, function () {
logger.warn('Trading engine listening at http://%s:%s', host, port)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment