|
|
@@ -24,9 +24,19 @@ import { getPluginStartupMessages } from './plugin/plugin-utils';
|
|
|
import { setProcessContext } from './process-context/process-context';
|
|
|
import { VENDURE_VERSION } from './version';
|
|
|
import { VendureWorker } from './worker/vendure-worker';
|
|
|
+import { NestApplicationOptions } from '@nestjs/common/interfaces/nest-application-options.interface';
|
|
|
+import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface';
|
|
|
|
|
|
export type VendureBootstrapFunction = (config: VendureConfig) => Promise<INestApplication>;
|
|
|
|
|
|
+export interface BootstrapOptions {
|
|
|
+ nestApplicationOptions: NestApplicationOptions;
|
|
|
+}
|
|
|
+
|
|
|
+export interface BootstrapWorkerOptions {
|
|
|
+ nestApplicationContextOptions: NestApplicationContextOptions
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* @description
|
|
|
* Bootstraps the Vendure server. This is the entry point to the application.
|
|
|
@@ -42,7 +52,7 @@ export type VendureBootstrapFunction = (config: VendureConfig) => Promise<INestA
|
|
|
* ```
|
|
|
* @docsCategory common
|
|
|
* */
|
|
|
-export async function bootstrap(userConfig: Partial<VendureConfig>): Promise<INestApplication> {
|
|
|
+export async function bootstrap(userConfig: Partial<VendureConfig>, options?: BootstrapOptions): Promise<INestApplication> {
|
|
|
const config = await preBootstrapConfig(userConfig);
|
|
|
Logger.useLogger(config.logger);
|
|
|
Logger.info(`Bootstrapping Vendure Server (pid: ${process.pid})...`);
|
|
|
@@ -58,6 +68,7 @@ export async function bootstrap(userConfig: Partial<VendureConfig>): Promise<INe
|
|
|
const app = await NestFactory.create(appModule.AppModule, {
|
|
|
cors,
|
|
|
logger: new Logger(),
|
|
|
+ ...options?.nestApplicationOptions
|
|
|
});
|
|
|
DefaultLogger.restoreOriginalLogLevel();
|
|
|
app.useLogger(new Logger());
|
|
|
@@ -99,7 +110,7 @@ export async function bootstrap(userConfig: Partial<VendureConfig>): Promise<INe
|
|
|
* ```
|
|
|
* @docsCategory worker
|
|
|
* */
|
|
|
-export async function bootstrapWorker(userConfig: Partial<VendureConfig>): Promise<VendureWorker> {
|
|
|
+export async function bootstrapWorker(userConfig: Partial<VendureConfig>, options?: BootstrapWorkerOptions): Promise<VendureWorker> {
|
|
|
const vendureConfig = await preBootstrapConfig(userConfig);
|
|
|
const config = disableSynchronize(vendureConfig);
|
|
|
config.logger.setDefaultContext?.('Vendure Worker');
|
|
|
@@ -113,6 +124,7 @@ export async function bootstrapWorker(userConfig: Partial<VendureConfig>): Promi
|
|
|
const WorkerModule = await import('./worker/worker.module.js').then(m => m.WorkerModule);
|
|
|
const workerApp = await NestFactory.createApplicationContext(WorkerModule, {
|
|
|
logger: new Logger(),
|
|
|
+ ...options?.nestApplicationContextOptions
|
|
|
});
|
|
|
DefaultLogger.restoreOriginalLogLevel();
|
|
|
workerApp.useLogger(new Logger());
|