Skip to content

Commit d9582aa

Browse files
committed
feat: udapte interfaces names
1 parent 65bf2ad commit d9582aa

5 files changed

Lines changed: 14 additions & 15 deletions

File tree

src/pages/api/sendmail.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { NextApiRequest, NextApiResponse } from 'next';
22
import { SendEmail } from 'src/services/email';
3-
import { SendEmailError } from 'src/services/email/SendEmailError';
43

54
export default async function handler(
65
req: NextApiRequest,

src/services/email/SendEmail.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { SendEmailUseCase } from './SendEmailUseCase';
2-
import { IEmailRepository } from './IEmailRepository';
2+
import { ISendEmailRepository } from './SendEmailRepository';
33
import { SendEmailError } from './SendEmailError';
44

55
describe('Email service', () => {
66
test('should send email successfully', async () => {
7-
const emailRepositoryMock: IEmailRepository = {
7+
const emailRepositoryMock: ISendEmailRepository = {
88
sendMail: jest.fn().mockResolvedValue({
99
success: true,
1010
messageId: 'mocked-id'
@@ -29,7 +29,7 @@ describe('Email service', () => {
2929
});
3030

3131
test('should not send email', async () => {
32-
const emailRepositoryMock: IEmailRepository = {
32+
const emailRepositoryMock: ISendEmailRepository = {
3333
sendMail: jest.fn().mockResolvedValue({
3434
success: false,
3535
messageId: 'mocked-id'
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export interface IEmailContactProps {
33
email: string;
44
}
55

6-
export interface SendMailDTO {
6+
export interface ISendMailDTO {
77
from: IEmailContactProps;
88
to: string;
99
subject: string;
@@ -16,6 +16,6 @@ export interface IEmailResponse {
1616
error?: string;
1717
}
1818

19-
export interface IEmailRepository {
20-
sendMail(data: SendMailDTO): Promise<IEmailResponse>;
19+
export interface ISendEmailRepository {
20+
sendMail(data: ISendMailDTO): Promise<IEmailResponse>;
2121
}

src/services/email/SendEmailUseCase.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { IEmailRepository, SendMailDTO } from './IEmailRepository';
1+
import { ISendEmailRepository, ISendMailDTO } from './SendEmailRepository';
22
import { SendEmailError } from './SendEmailError';
33

44
export class SendEmailUseCase {
5-
constructor(private mailProvider: IEmailRepository) {}
5+
constructor(private mailProvider: ISendEmailRepository) {}
66

7-
async execute(data: SendMailDTO) {
7+
async execute(data: ISendMailDTO) {
88
const response = await this.mailProvider.sendMail(data);
99

1010
if (!response.success) {

src/services/email/providers/resend.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Resend } from 'resend';
22
import {
3-
SendMailDTO,
4-
IEmailRepository,
3+
ISendMailDTO,
4+
ISendEmailRepository,
55
IEmailResponse
6-
} from '../IEmailRepository';
6+
} from '../SendEmailRepository';
77

8-
export class ResendMailProvider implements IEmailRepository {
8+
export class ResendMailProvider implements ISendEmailRepository {
99
private resend;
1010

1111
constructor() {
@@ -17,7 +17,7 @@ export class ResendMailProvider implements IEmailRepository {
1717
this.resend = new Resend(apiKey);
1818
}
1919

20-
async sendMail(messageData: SendMailDTO): Promise<IEmailResponse> {
20+
async sendMail(messageData: ISendMailDTO): Promise<IEmailResponse> {
2121
const { from, message, subject, to } = messageData;
2222

2323
try {

0 commit comments

Comments
 (0)