MCPcopy
hub / github.com/midwayjs/midway / init

Method init

packages/core/src/service/frameworkService.ts:62–242  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60
61 @Init()
62 protected async init() {
63 // register base config hook
64 this.decoratorService.registerPropertyHandler(
65 CONFIG_KEY,
66 (propertyName, meta) => {
67 if (meta.identifier === ALL_VALUE_KEY) {
68 return this.configService.getConfiguration();
69 } else {
70 return this.configService.getConfiguration(
71 meta.identifier ?? propertyName
72 );
73 }
74 }
75 );
76
77 // register @Logger decorator handler
78 this.decoratorService.registerPropertyHandler(
79 LOGGER_KEY,
80 (propertyName, meta) => {
81 return this.loggerService.getLogger(meta.identifier ?? propertyName);
82 }
83 );
84
85 // register @App decorator handler
86 this.decoratorService.registerPropertyHandler(
87 APPLICATION_KEY,
88 (propertyName, meta) => {
89 if (meta.type) {
90 const framework = this.applicationManager.getApplication(meta.type);
91 if (!framework) {
92 throw new MidwayCommonError(`Framework ${meta.type} not Found`);
93 }
94 return framework;
95 } else {
96 return this.getMainApp();
97 }
98 }
99 );
100
101 // register @MainApp decorator handler
102 this.decoratorService.registerPropertyHandler(
103 MAIN_APPLICATION_KEY,
104 (propertyName, meta) => {
105 return this.getMainApp();
106 }
107 );
108
109 this.decoratorService.registerPropertyHandler(
110 PLUGIN_KEY,
111 (propertyName, meta) => {
112 return this.getMainApp()[meta.identifier ?? propertyName];
113 }
114 );
115
116 this.decoratorService.registerPropertyHandler(
117 FACTORY_SERVICE_CLIENT_KEY,
118 (
119 propertyName,

Callers

nothing calls this directly

Calls 15

getMainAppMethod · 0.95
filterProtoFrameworkFunction · 0.85
getDefaultClientNameMethod · 0.80
listModuleMethod · 0.80
getProviderUUIdMethod · 0.80
initializeMethod · 0.80
addFrameworkMethod · 0.80
hasFrameworkMethod · 0.80
loadAspectMethod · 0.80

Tested by

no test coverage detected