Last active
August 29, 2015 14:12
-
-
Save maxant/605c94552a5ece6701ad to your computer and use it in GitHub Desktop.
Web Server parts of trading-engine-parent3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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