agents defs from DB
This commit is contained in:
@@ -32,30 +32,6 @@ class EICModel extends Model {
|
||||
this.setPrivileges(resource, privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} action
|
||||
* @param {*} resource
|
||||
* @returns {object}
|
||||
*/
|
||||
getApiEndpoint(action, resource=null) {
|
||||
resource = resource || this.resource;
|
||||
for(let ApiBizObj of Object.keys(app.config.api)) {
|
||||
|
||||
//If called without real ids
|
||||
if(ApiBizObj==resource) return(JSON.parse(JSON.stringify(app.config.api[ApiBizObj][action])));
|
||||
|
||||
//If called with real ids
|
||||
let re = new RegExp('^'+ApiBizObj.replace(/\//g,'\\/').replace(/\{\w+\}/gi,'([0-9a-zA-Z]+)')+'$', 'm')
|
||||
if(resource.match(re)) {
|
||||
if(app.config.api[ApiBizObj].hasOwnProperty(action)) return(JSON.parse(JSON.stringify(app.config.api[ApiBizObj][action])));
|
||||
else console.error(`No API endpoint for action "${action}" on resource "${resource}"`)
|
||||
}
|
||||
}
|
||||
console.error(`No API service for resource:${resource}`)
|
||||
return({ "method":null, "uri": null });
|
||||
}
|
||||
|
||||
setPrivileges(resource, privileges) {
|
||||
this.resource = resource;
|
||||
this.privileges = privileges || [];
|
||||
|
||||
Reference in New Issue
Block a user