mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
26 lines
589 B
JavaScript
26 lines
589 B
JavaScript
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
|
|
} |