diff --git a/packages/core/package.json b/packages/core/package.json index 87c941391d..6bba6821c5 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -44,6 +44,7 @@ "@nestjs/apollo": "^12.0.7", "@nestjs/common": "10.2.1", "@nestjs/core": "10.2.1", + "@nestjs/devtools-integration": "0.1.5", "@nestjs/graphql": "12.0.8", "@nestjs/platform-express": "10.2.1", "@nestjs/terminus": "10.0.1", diff --git a/packages/core/src/app.module.ts b/packages/core/src/app.module.ts index 219b41d898..1d9398c77d 100644 --- a/packages/core/src/app.module.ts +++ b/packages/core/src/app.module.ts @@ -12,6 +12,7 @@ import { I18nService } from './i18n/i18n.service'; import { PluginModule } from './plugin/plugin.module'; import { ProcessContextModule } from './process-context/process-context.module'; import { ServiceModule } from './service/service.module'; +import { DevtoolsModule } from "@nestjs/devtools-integration"; @Module({ imports: [ @@ -23,6 +24,10 @@ import { ServiceModule } from './service/service.module'; HealthCheckModule, ServiceModule, ConnectionModule, + DevtoolsModule.register({ + port: process.env.DEVTOOLS_PORT ? +process.env.DEVTOOLS_PORT : 8000, + http: process.env.NODE_ENV !== 'production' && process.env.ENABLE_DEVTOOLS === 'true', + }), ], }) export class AppModule implements NestModule, OnApplicationShutdown { diff --git a/packages/core/src/bootstrap.ts b/packages/core/src/bootstrap.ts index fd54076cf9..ebe8f8d65f 100644 --- a/packages/core/src/bootstrap.ts +++ b/packages/core/src/bootstrap.ts @@ -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; +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): Promise { +export async function bootstrap(userConfig: Partial, options?: BootstrapOptions): Promise { 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): Promise): Promise): Promise { +export async function bootstrapWorker(userConfig: Partial, options?: BootstrapWorkerOptions): Promise { const vendureConfig = await preBootstrapConfig(userConfig); const config = disableSynchronize(vendureConfig); config.logger.setDefaultContext?.('Vendure Worker'); @@ -113,6 +124,7 @@ export async function bootstrapWorker(userConfig: Partial): 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()); diff --git a/yarn.lock b/yarn.lock index 2d285a9514..f3190f9daf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3708,6 +3708,14 @@ path-to-regexp "3.2.0" tslib "2.6.1" +"@nestjs/devtools-integration@0.1.5": + version "0.1.5" + resolved "https://registry.yarnpkg.com/@nestjs/devtools-integration/-/devtools-integration-0.1.5.tgz#373aebe93632dd0f1bc46b714c6720951f35f87b" + integrity sha512-iwxvfxa3kzOulG/Fje82Ww80OVsA8rzYR+UAEKrdGExRRGQRGQ0+bHfG0XLlPG3XIuM5J2MRMo7x1bN8ZIs9Gg== + dependencies: + chalk "^4.1.2" + node-fetch "^2.6.9" + "@nestjs/graphql@12.0.8": version "12.0.8" resolved "https://registry.yarnpkg.com/@nestjs/graphql/-/graphql-12.0.8.tgz#15143b76dfb5fa4dc880d68a1bf2f7159ea077b6" @@ -14102,7 +14110,7 @@ node-fetch@2.6.7: dependencies: whatwg-url "^5.0.0" -node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.12, node-fetch@^2.6.7, node-fetch@^2.7.0: +node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.12, node-fetch@^2.6.7, node-fetch@^2.6.9, node-fetch@^2.7.0: version "2.7.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==