WS fixes
This commit is contained in:
@@ -11,7 +11,7 @@ class LetsEncrypt{
|
||||
static AcmeClient = AcmeClient;
|
||||
|
||||
constructor(options){
|
||||
this.loadAccountKey(options.accountKeyPath || '~/le_key', (key)=>{
|
||||
this.loadAccountKey(options.accountKeyPath || './le_key.cert', (key)=>{
|
||||
this.client = new AcmeClient.Client({
|
||||
directoryUrl: options.directoryUrl || AcmeClient.directory.letsencrypt.production,
|
||||
accountKey: key,
|
||||
|
||||
@@ -25,11 +25,11 @@ function ModelPs(model){
|
||||
},
|
||||
get(target, propKey, receiver) {
|
||||
if(propKey == 'constructor') return target.constructor;
|
||||
if(propKey === 'isproxy') return 'YESSSSSSSSS'
|
||||
const targetValue = Reflect.get(target, propKey, receiver);
|
||||
if (typeof targetValue === 'function') {
|
||||
return function(...args){
|
||||
let res = targetValue.apply(this, args); // (A)
|
||||
// let res = targetValue.apply(this, args); // (A)
|
||||
let res = Reflect.apply(targetValue, this, args);
|
||||
if(targetValue.constructor.name === 'AsyncFunction'){
|
||||
res.then(function(res){
|
||||
publish(propKey, res, ...args);
|
||||
|
||||
+25
-29
@@ -127,36 +127,33 @@ class Table{
|
||||
try{
|
||||
// Check to see if entry name changed.
|
||||
if(data[this.constructor._key] && data[this.constructor._key] !== this[this.constructor._key]){
|
||||
// Remove the index key from the tables members list.
|
||||
await client.SREM(
|
||||
redisPrefix(this.constructor.name),
|
||||
this[this.constructor._key]
|
||||
);
|
||||
|
||||
// Merge the current data into with the updated data
|
||||
let newData = Object.assign({}, this, data);
|
||||
// Add the key to the members for this redis table
|
||||
await client.SADD(
|
||||
redisPrefix(this.constructor.name),
|
||||
data[this.constructor._key]
|
||||
);
|
||||
|
||||
// Remove the updated failed so it doesnt keep it
|
||||
delete newData.updated;
|
||||
|
||||
// Create a new record for the updated entry. If that succeeds,
|
||||
// delete the old recored
|
||||
let newObject = await this.constructor.create(newData);
|
||||
|
||||
if(newObject){
|
||||
await this.remove();
|
||||
return newObject;
|
||||
}
|
||||
}else{
|
||||
// Update what ever fields that where passed.
|
||||
|
||||
// Validate the passed data, ignoring required fields.
|
||||
data = objValidate.processKeys(this.constructor._keyMap, data, true);
|
||||
|
||||
// Loop over the data fields and apply them to redis
|
||||
for(let key of Object.keys(data)){
|
||||
this[key] = data[key];
|
||||
await client.HSET(
|
||||
redisPrefix(`${this.constructor.name}_${this[this.constructor._key]}`),
|
||||
key, String(data[key])
|
||||
);
|
||||
}
|
||||
}
|
||||
// Update what ever fields that where passed.
|
||||
|
||||
// Validate the passed data, ignoring required fields.
|
||||
data = objValidate.processKeys(this.constructor._keyMap, data, true);
|
||||
|
||||
// Loop over the data fields and apply them to redis
|
||||
for(let key of Object.keys(data)){
|
||||
this[key] = data[key];
|
||||
await client.HSET(
|
||||
redisPrefix(`${this.constructor.name}_${this[this.constructor._key]}`),
|
||||
key, String(data[key])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
|
||||
@@ -171,7 +168,6 @@ class Table{
|
||||
|
||||
try{
|
||||
// Remove the index key from the tables members list.
|
||||
|
||||
await client.SREM(
|
||||
redisPrefix(this.constructor.name),
|
||||
this[this.constructor._key]
|
||||
@@ -183,7 +179,7 @@ class Table{
|
||||
);
|
||||
|
||||
// Return the number of removed values to the caller.
|
||||
return count;
|
||||
return this;
|
||||
|
||||
} catch(error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user