|
@@ -1,4 +1,4 @@
|
|
|
-const debug = require('debug')('crowi:InterceptorManager')
|
|
|
|
|
|
|
+const logger = require('@alias/logger')('growi:InterceptorManager');
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* the manager class of Interceptor
|
|
* the manager class of Interceptor
|
|
@@ -23,7 +23,7 @@ class InterceptorManager {
|
|
|
*/
|
|
*/
|
|
|
addInterceptors(interceptors) {
|
|
addInterceptors(interceptors) {
|
|
|
const interceptorIds = interceptors.map((i) => i.getId());
|
|
const interceptorIds = interceptors.map((i) => i.getId());
|
|
|
- debug(`adding interceptors '${interceptorIds}'`);
|
|
|
|
|
|
|
+ logger.debug(`adding interceptors '${interceptorIds}'`);
|
|
|
this.interceptors = this.interceptors.concat(interceptors);
|
|
this.interceptors = this.interceptors.concat(interceptors);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -34,7 +34,7 @@ class InterceptorManager {
|
|
|
* @param {any} args
|
|
* @param {any} args
|
|
|
*/
|
|
*/
|
|
|
process(contextName, ...args) {
|
|
process(contextName, ...args) {
|
|
|
- debug(`processing the context '${contextName}'`);
|
|
|
|
|
|
|
+ logger.debug(`processing the context '${contextName}'`);
|
|
|
|
|
|
|
|
// filter only contexts matches to specified 'contextName'
|
|
// filter only contexts matches to specified 'contextName'
|
|
|
const matchInterceptors = this.interceptors.filter((i) => i.isInterceptWhen(contextName));
|
|
const matchInterceptors = this.interceptors.filter((i) => i.isInterceptWhen(contextName));
|
|
@@ -42,8 +42,8 @@ class InterceptorManager {
|
|
|
const parallels = matchInterceptors.filter((i) => i.isProcessableParallel());
|
|
const parallels = matchInterceptors.filter((i) => i.isProcessableParallel());
|
|
|
const sequentials = matchInterceptors.filter((i) => !i.isProcessableParallel());
|
|
const sequentials = matchInterceptors.filter((i) => !i.isProcessableParallel());
|
|
|
|
|
|
|
|
- debug(`${parallels.length} parallel interceptors found.`);
|
|
|
|
|
- debug(`${sequentials.length} sequencial interceptors found.`);
|
|
|
|
|
|
|
+ logger.debug(`${parallels.length} parallel interceptors found.`);
|
|
|
|
|
+ logger.debug(`${sequentials.length} sequencial interceptors found.`);
|
|
|
|
|
|
|
|
return Promise.all(
|
|
return Promise.all(
|
|
|
// parallel
|
|
// parallel
|
|
@@ -57,7 +57,7 @@ class InterceptorManager {
|
|
|
}, Promise.resolve(...args)/* initial Promise */)
|
|
}, Promise.resolve(...args)/* initial Promise */)
|
|
|
])
|
|
])
|
|
|
).then(() => {
|
|
).then(() => {
|
|
|
- debug(`end processing the context '${contextName}'`);
|
|
|
|
|
|
|
+ logger.debug(`end processing the context '${contextName}'`);
|
|
|
return;
|
|
return;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -65,12 +65,12 @@ class InterceptorManager {
|
|
|
doProcess(interceptor, contextName, ...args) {
|
|
doProcess(interceptor, contextName, ...args) {
|
|
|
return interceptor.process(contextName, ...args)
|
|
return interceptor.process(contextName, ...args)
|
|
|
.then((...results) => {
|
|
.then((...results) => {
|
|
|
- debug(`processing '${interceptor.getId()}' in the context '${contextName}'`);
|
|
|
|
|
|
|
+ logger.debug(`processing '${interceptor.getId()}' in the context '${contextName}'`);
|
|
|
return Promise.resolve(...results);
|
|
return Promise.resolve(...results);
|
|
|
})
|
|
})
|
|
|
.catch((reason) => {
|
|
.catch((reason) => {
|
|
|
- debug(`failed when processing '${interceptor.getId()}' in the context '${contextName}'`);
|
|
|
|
|
- debug(reason);
|
|
|
|
|
|
|
+ logger.debug(`failed when processing '${interceptor.getId()}' in the context '${contextName}'`);
|
|
|
|
|
+ logger.debug(reason);
|
|
|
return Promise.resolve(...args);
|
|
return Promise.resolve(...args);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|