1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix client registration

This commit is contained in:
ivaosthu 2016-11-05 12:42:58 +01:00 committed by Ivar Conradi Østhus
parent b04b376dbb
commit eca27ef91e
2 changed files with 4 additions and 3 deletions

View File

@ -9,9 +9,9 @@ module.exports = function (db) {
return db(TABLE)
.where('app_name', details.appName)
.where('instance_id', details.instanceId)
.where('client_ip', details.clientIp)
.update({
last_seen: 'now()',
client_ip: details.clientIp,
});
}
@ -24,11 +24,11 @@ module.exports = function (db) {
}
function insert (details) {
console.log(details);
return db(TABLE)
.count('*')
.where('app_name', details.appName)
.where('instance_id', details.instanceId)
.where('client_ip', details.clientIp)
.map(row => ({ count: row.count }))
.then(rows => {
if (rows[0].count > 0) {

View File

@ -42,11 +42,12 @@ module.exports = function (app, config) {
app.post('/client/register', (req, res) => {
const data = req.body;
const clientIp = req.ip;
clientStrategiesDb.insert(data.appName, data.strategies)
.then(() => clientInstancesDb.insert({
appName: data.appName,
instanceId: data.instanceId,
clientIp: req.ip,
clientIp,
}))
.then(() => console.log('new client registerd'))
.catch((error) => logger.error('Error registering client', error));