Commit forgotten file

This commit is contained in:
Thomas FORGIONE 2015-07-20 15:11:59 +02:00
parent a308b4e93f
commit df2d8b8083
2 changed files with 35 additions and 0 deletions

32
posts/coin-id/index.js Normal file
View File

@ -0,0 +1,32 @@
var pg = require('pg');
var secret = require('../../private');
var Log = require('../../lib/NodeLog.js');
function insertCoinId(client, release, exp_id, coin_ids) {
if (coin_ids.length > 0) {
client.query(
'INSERT INTO Coin(exp_id, coin_id) VALUES ($1, $2);',
[exp_id,coin_ids.shift()],
function(err, result) {
if (err !== null)
Log.dberror(err + ' coin-id');
if (coin_ids.length === 0)
release();
else
insertCoinId(client, release, exp_id, coin_ids);
}
);
}
}
module.exports.index = function(req, res) {
pg.connect(secret.url, function(err, client, release) {
insertCoinId(client, release, req.session.exp_id, req.body.indices);
});
res.setHeader('Content-Type', 'text/html');
res.send("");
};

3
posts/coin-id/urls.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
'/coin-id': 'index'
};