Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
this.containerLoader.initialize();
this.applicationContext.registerObject('appDir', this.appDir);
// 如果没有关闭autoLoad 则进行load
this.containerLoader.loadDirectory(containerConfig);
// register handler for container
this.containerLoader.registerHook(MidwayHandlerKey.CONFIG, (key: string) => {
return safelyGet(key, this.config);
});
this.containerLoader.registerHook(MidwayHandlerKey.PLUGIN, (key: string) => {
return this.app[key] || this.pluginContext.get(key);
});
this.containerLoader.registerHook(MidwayHandlerKey.LOGGER, (key: string) => {
if (this.app.getLogger) {
return this.app.getLogger(key);
}
return this.options.logger;
});
}
registerDecorator() {
// register handler for container
this.loader.registerHook(MidwayHandlerKey.CONFIG, key => {
return this.globalConfig[key];
});
this.loader.registerHook(MidwayHandlerKey.PLUGIN, (key, target) => {
const ctx = target[REQUEST_OBJ_CTX_KEY] || {};
return ctx[key];
});
this.loader.registerHook(MidwayHandlerKey.LOGGER, (key, target) => {
const ctx = target[REQUEST_OBJ_CTX_KEY] || {};
return ctx['logger'];
});
}