I have a Email module that a created to use to send e-mail's and i use Resend API to send those e-mail's... The error started when i change my EmailService... So now i call InterfaceEmailService, and EmailService implements this interface. But when i try to run the project, the error occurs...
email.module
@Module({
imports: [ConfigModule.forRoot()],
providers: [
{
provide: 'IEmailService',
useClass: EmailService,
},
],
exports: ['IEmailService'],
})
export class EmailModule { }
email.service
@Injectable()
export class EmailService implements IEmailService {
private readonly resendPrivateKey = this.configService.get<string>('RESEND_API_KEY', '');
private readonly resend = new Resend(this.resendPrivateKey);
private readonly fromEmail = '[email protected]';
constructor(private readonly configService: ConfigService) { }
async sendMail(to: string, subject: string, html: string): Promise<void> {
try {
await this.resend.emails.send({
from: this.fromEmail,
to: to,
subject: subject,
html: html,
});
} catch (error: any) {
console.error(error);
}
}
}
interface.email.service
export interface IEmailService {
sendMail(to: string, subject: string, html: string): Promise<void>;
}
I try to change my .env, change imports...