nest-modules/mailer

LiquidJs adapter error on application startup

Opened this issue · 0 comments

Describe the bug

Using LiquidAdapter() won't work in the MailerModule.forRoot() method.

/test-project/node_modules/@nestjs-modules/mailer/dist/adapters/liquid.adapter.js:9
        Object.assign(this.config, config);
               ^

TypeError: Cannot convert undefined or null to object
    at Function.assign (<anonymous>)
    at new LiquidAdapter (/test-project/node_modules/@nestjs-modules/mailer/dist/adapters/liquid.adapter.js:9:16)
    at Object.<anonymous> (/test-project/src/app.module.ts:12:18)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/test-project/src/main.ts:2:1)

To Reproduce
Steps to reproduce the behavior:

  1. Configure MailerModule:
@Module({
  imports: [
    MailerModule.forRoot({
      transport: 'smtps://user@domain.com:pass@smtp.domain.com',
      template: {
        dir: __dirname + '/templates',
        adapter: new LiquidAdapter(),
        options: {
          strict: true,
        },
      },
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
  1. The app can't run, it encounters a TypeError

Additional context
This is likely related to the config not being initialized in liquid.adapter.ts

private config: Partial<Liquid['options']>;

constructor(config?: Partial<Liquid['options']>) {
Object.assign(this.config, config);
}