Explorar o código

fix(email-plugin): Move server setup to onBootstrap method

Michael Bromley %!s(int64=6) %!d(string=hai) anos
pai
achega
5f7a65e669
Modificáronse 1 ficheiros con 6 adicións e 3 borrados
  1. 6 3
      packages/email-plugin/src/plugin.ts

+ 6 - 3
packages/email-plugin/src/plugin.ts

@@ -146,9 +146,6 @@ export class EmailPlugin implements VendurePlugin {
     /** @internal */
     configure(config: Required<VendureConfig>): Required<VendureConfig> | Promise<Required<VendureConfig>> {
         if (isDevModeOptions(this.options) && this.options.mailboxPort !== undefined) {
-            this.devMailbox = new DevMailbox();
-            this.devMailbox.serve(this.options);
-            this.devMailbox.handleMockEvent((handler, event) => this.handleEvent(handler, event));
             const route = 'mailbox';
             config.middleware.push({
                 handler: createProxyHandler({ port: this.options.mailboxPort, route, label: 'Dev Mailbox' }),
@@ -165,6 +162,12 @@ export class EmailPlugin implements VendurePlugin {
         this.emailSender = new EmailSender();
         this.generator = new HandlebarsMjmlGenerator();
 
+        if (isDevModeOptions(this.options) && this.options.mailboxPort !== undefined) {
+            this.devMailbox = new DevMailbox();
+            this.devMailbox.serve(this.options);
+            this.devMailbox.handleMockEvent((handler, event) => this.handleEvent(handler, event));
+        }
+
         await this.setupEventSubscribers();
         if (this.generator.onInit) {
             await this.generator.onInit.call(this.generator, this.options);