clientlinker
Version:
Linker all clients whether rpc, addon, http request, mock data, local file ...
24 lines (20 loc) • 557 B
JavaScript
exports.newNotFoundError = newNotFoundError;
function newNotFoundError(type, runtime) {
const err = new Error('CLIENTLINKER:NotFound,' + runtime.action);
err.CLIENTLINKER_TYPE = type;
return err;
}
exports.parseActionCache = {};
exports.parseAction = parseAction;
function parseAction(action) {
let cache = exports.parseActionCache[action];
if (!cache) {
const arr = action.split(/\.|:/);
const clientName = arr.shift();
cache = exports.parseActionCache[action] = {
clientName: clientName,
method: arr.join('.')
};
}
return cache;
}