UNPKG

btnexus-node

Version:
45 lines (37 loc) 1.2 kB
/** * Blackout Technologies Nexus, Hook data abstract * @author Marc Fiedler * @copyright 2020 Blackout Technologies, all rights reserved */ // Use Strict mode ECMA Script 5+ "use_strict"; module.exports = class NexusData{ constructor(config, api){ this.api = api; this.config = config; } put(key, value, callback){ this.api.post("hookDataLoad", {hookId: this.config.id, key: key}, (success, resp) => { if( success ){ var val = resp.value; if( val == undefined ){ val = []; } console.log("loaded: "); console.dir(resp); val.push(value); console.log("Saving"); console.dir(val); this.save(key, val, callback); }else{ console.dir(resp); } }); } save(key, value, callback){ this.api.post("hookDataSave", {hookId: this.config.id, key: key, value: value}, callback); } load(key, callback){ this.api.post("hookDataLoad", {hookId: this.config.id, key: key}, callback); } }