Closed kingdun3284 closed 3 years ago
Yes, the boot
and init
methods are called after the controllers and routes are resolved. This is during this step that the OpenAPI document is created, thus the init methods have not been called yet. This is something that won't change in the future because it would require a lot of work to change the internal architecture and probably very complex code to make it work.
The only thing that I can suggest in your case is, as you mentionned, to boot the service before calling createApp
.
I would recommend to use services.boot(Service)
instead of service.boot
to avoid the method to be executed a second time by createApp
.
const services = new ServiceManager();
serviceManager.set(Service, service);
await serviceManager.boot(Service);
const app = await createApp(AppController, { serviceManager: services });
Version of FoalTS: 2.4.0
Try to access service inside ApiDefineSchema Decorator and found that the service haven't been initialized even with
in index.ts, thus, need to manually call boot function before createApp.