@vida-global/core 1.4.2 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,11 +7,13 @@ const AUTH_CALLBACK_NAME = 'authenticateRequest';
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class VidaServerController {
|
|
10
|
-
#afterCallbacks
|
|
11
|
-
#
|
|
12
|
-
#
|
|
10
|
+
#afterCallbacks = [];
|
|
11
|
+
#afterCallbacksToSkip = [];
|
|
12
|
+
#beforeCallbacks = [];
|
|
13
|
+
#beforeCallbacksToSkip = [];
|
|
14
|
+
#callbacksSetUp = false;
|
|
13
15
|
#params;
|
|
14
|
-
#rendered
|
|
16
|
+
#rendered = false;
|
|
15
17
|
#request;
|
|
16
18
|
#response;
|
|
17
19
|
|
|
@@ -391,24 +393,40 @@ class VidaServerController {
|
|
|
391
393
|
}
|
|
392
394
|
|
|
393
395
|
|
|
396
|
+
skipBeforeCallback(callback, options={}) {
|
|
397
|
+
this.#addCallback(callback, options, this.#beforeCallbacksToSkip);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
skipAfterCallback(callback, options={}) {
|
|
402
|
+
this.#addCallback(callback, options, this.#afterCallbacksToSkip);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
|
|
394
406
|
#addCallback(callback, options, callbacksList) {
|
|
395
407
|
callbacksList.push({ callback, options });
|
|
396
408
|
}
|
|
397
409
|
|
|
398
410
|
|
|
399
411
|
async runBeforeCallbacks(actionName) {
|
|
400
|
-
return await this.#runCallbacks(this.#beforeCallbacks, actionName);
|
|
412
|
+
return await this.#runCallbacks(this.#beforeCallbacks, this.#beforeCallbacksToSkip, actionName);
|
|
401
413
|
}
|
|
402
414
|
|
|
403
415
|
|
|
404
416
|
async runAfterCallbacks(actionName) {
|
|
405
|
-
return await this.#runCallbacks(this.#afterCallbacks, actionName);
|
|
417
|
+
return await this.#runCallbacks(this.#afterCallbacks, this.#afterCallbacksToSkip, actionName);
|
|
406
418
|
}
|
|
407
419
|
|
|
408
420
|
|
|
409
|
-
async #runCallbacks(callbacksList, actionName) {
|
|
421
|
+
async #runCallbacks(callbacksList, callbacksToSkipList, actionName) {
|
|
422
|
+
let toSkip = callbacksToSkipList.filter(({ callback, options }) => {
|
|
423
|
+
return this.#shouldRunCallback(actionName, options);
|
|
424
|
+
});
|
|
425
|
+
toSkip = toSkip.map(({ callback }) => callback);
|
|
426
|
+
|
|
410
427
|
for (const { callback, options } of callbacksList) {
|
|
411
428
|
if (!this.#shouldRunCallback(actionName, options)) continue;
|
|
429
|
+
if (toSkip.includes(callback)) continue;
|
|
412
430
|
const result = await this.#runCallback(callback)
|
|
413
431
|
if (result === false) return false;
|
|
414
432
|
}
|