import { Module } from '@nestjs/common';

import { AppController } from './app.controller';
import { AppService } from './app.service';
import { MailerModule, MailerService } from '@nestjs-modules/mailer';
import { join } from 'path';
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter';

@Module({
  imports: [MailerModule.forRootAsync({
    useFactory: () => ({
      transport: {
        host: 'email-smtp.us-east-2.amazonaws.com',
        secure: false,
        port: 587,
        auth: {
          user: process.env.AMAZON_USER,
          pass: process.env.AMAZON_PASSWORD,
        },
      },
      defaults: {
        from: '"No Reply" <noreply@example.com>',
      },
      template: {
        dir: join(__dirname, '..','assets'),
        adapter: new HandlebarsAdapter({
          eq: function (a, b) {
            return a === b;
          },
        }),
        options: {
          strict: true,
        },
      },
    }),
  }),],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
