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:
parent
b04b376dbb
commit
eca27ef91e
@ -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) {
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user