mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Abstracted Nest "Provider" registration from boot
This allows us to make underlying changes to how it works
This commit is contained in:
parent
e285ddcafa
commit
cca1978b2f
2 changed files with 10 additions and 1 deletions
|
@ -393,7 +393,7 @@ async function initServices({config}) {
|
|||
async function initNestDependencies() {
|
||||
debug('Begin: initNestDependencies');
|
||||
const GhostNestApp = require('@tryghost/ghost');
|
||||
const providers = GhostNestApp.AppModule.providers;
|
||||
const providers = [];
|
||||
const urlUtils = require('./shared/url-utils');
|
||||
providers.push({
|
||||
provide: 'models',
|
||||
|
@ -436,6 +436,9 @@ async function initNestDependencies() {
|
|||
provide: 'settings',
|
||||
useValue: require('./shared/settings-cache')
|
||||
});
|
||||
for (const provider of providers) {
|
||||
GhostNestApp.addProvider(provider);
|
||||
}
|
||||
debug('End: initNestDependencies');
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'reflect-metadata';
|
|||
import {AppModule} from './nestjs/app.module';
|
||||
import {NestApplication, NestFactory} from '@nestjs/core';
|
||||
import {registerEvents} from './common/decorators/handle-event.decorator';
|
||||
import {ClassProvider, ValueProvider} from '@nestjs/common';
|
||||
|
||||
export async function create() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
@ -10,6 +11,11 @@ export async function create() {
|
|||
return app;
|
||||
}
|
||||
|
||||
export function addProvider(obj: ClassProvider | ValueProvider) {
|
||||
AppModule.providers?.push(obj);
|
||||
AppModule.exports?.push(obj.provide);
|
||||
}
|
||||
|
||||
export {
|
||||
AppModule
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue