Will be redoing the event interface for subscriptions, some work for the wi and crash fixes

This commit is contained in:
KimLS
2017-01-30 23:22:52 -08:00
parent a8699eb40c
commit d5bd773a46
17 changed files with 205 additions and 98 deletions
+26
View File
@@ -0,0 +1,26 @@
var auth = require('../core/jwt_auth.js').auth;
function RegisterFunction(path, fn, app, api) {
app.post(path, auth, function (req, res) {
var params = req.body.params || [];
api.Call(fn, params)
.then(function(value) {
res.send({ response: value });
})
.catch(function(reason) {
if(reason.message) {
res.send({ status: reason.message });
}
else if(reason === 'Not connected to world server.') {
res.send({ status: 'ENCONNECTED' });
} else {
res.sendStatus(500);
}
});
});
}
module.exports = {
'Register': RegisterFunction
}
+10 -31
View File
@@ -1,37 +1,16 @@
var auth = require('../core/jwt_auth.js').auth;
const common = require('./common.js');
var RegisterEQW = function(app, api) {
app.post('/api/eqw/islocked', auth, function (req, res) {
api.Call('EQW::IsLocked', [])
.then(function(value) {
res.send({ response: value });
})
.catch(function(reason) {
res.sendStatus(500);
});
});
app.post('/api/eqw/lock', auth, function (req, res) {
api.Call('EQW::Lock', [])
.then(function(value) {
res.send({ response: value });
})
.catch(function(reason) {
res.sendStatus(500);
});
});
app.post('/api/eqw/unlock', auth, function (req, res) {
api.Call('EQW::Unlock', [])
.then(function(value) {
res.send({ response: value });
})
.catch(function(reason) {
res.sendStatus(500);
});
});
common.Register('/api/eqw/getconfig', 'EQW::GetConfig', app, api);
common.Register('/api/eqw/islocked', 'EQW::IsLocked', app, api);
common.Register('/api/eqw/lock', 'EQW::Lock', app, api);
common.Register('/api/eqw/unlock', 'EQW::Unlock', app, api);
common.Register('/api/eqw/getplayercount', 'EQW::GetPlayerCount', app, api);
common.Register('/api/eqw/getzonecount', 'EQW::GetZoneCount', app, api);
common.Register('/api/eqw/getlaunchercount', 'EQW::GetLauncherCount', app, api);
common.Register('/api/eqw/getloginservercount', 'EQW::GetLoginServerCount', app, api);
};
module.exports = {
'Register': RegisterEQW
}
}