salix/services/loopback/common/methods/workerMana/getCurrentWorkerMana.js

21 lines
599 B
JavaScript

module.exports = Self => {
Self.remoteMethodCtx('getCurrentWorkerMana', {
description: 'Returns the mana of the logged worker',
accessType: 'READ',
accepts: [],
returns: {
type: 'number',
root: true
},
http: {
path: `/getCurrentWorkerMana`,
verb: 'GET'
}
});
Self.getCurrentWorkerMana = async ctx => {
let loggedWorkerId = ctx.req.accessToken.userId;
return await Self.rawSql(`SELECT used AS mana FROM vn.manaSpellers WHERE worker = ?`, [loggedWorkerId]);
};
};