Remove Cloudflare mailer implementation, update dependencies and updated code to reflect stricter EsLint settings

Deleted CloudflareMailer class and its implementation from the mailers package. Updated dependencies across various packages, converting certain imports to use `type` only, and bumped versions for packages like `react-query`, `lucide-react`, and others.
This commit is contained in:
gbuomprisco
2024-08-01 14:57:55 +02:00
parent 5c28eaabeb
commit 23154c366d
48 changed files with 607 additions and 469 deletions

View File

@@ -19,12 +19,6 @@ Make sure the app installs the `@kit/mailers` package before using it.
By default, the package uses `nodemailer`.
To use Cloudflare, please set the environment variable `MAILER_PROVIDER` to `cloudflare`.
```
MAILER_PROVIDER=cloudflare
```
To use [Resend](https:///resend.com)'s HTTP API, please set the environment variable `MAILER_PROVIDER` to `resend`.
```
@@ -48,10 +42,6 @@ async function sendEmail() {
}
```
## Cloudflare
If you're using the `cloudflare` provider, please also read the instructions of the package [Vercel Email](https://github.com/Sh4yy/vercel-email) to setup your Workers.
## Resend
If you're using the `resend` provider, please add the following environment variables:

View File

@@ -1,31 +0,0 @@
import 'server-only';
import Email from 'vercel-email';
import { z } from 'zod';
import { Mailer } from '../../mailer';
import { MailerSchema } from '../../schema/mailer.schema';
type Config = z.infer<typeof MailerSchema>;
/**
* A class representing a mailer using Cloudflare's Workers thanks to the 'vercel-email' package.
* @implements {Mailer}
*/
export class CloudflareMailer implements Mailer {
async sendEmail(config: Config) {
const schema = {
to: config.to,
from: config.from,
subject: config.subject,
};
const content =
'text' in config ? { text: config.text } : { html: config.html };
return Email.send({
...schema,
...content,
});
}
}

View File

@@ -3,7 +3,7 @@ import 'server-only';
import { z } from 'zod';
import { Mailer } from '../../mailer';
import { MailerSchema } from '../../schema/mailer.schema';
import type { MailerSchema } from '../../schema/mailer.schema';
import { getSMTPConfiguration } from '../../smtp-configuration';
type Config = z.infer<typeof MailerSchema>;

View File

@@ -3,7 +3,7 @@ import 'server-only';
import { z } from 'zod';
import { Mailer } from '../../mailer';
import { MailerSchema } from '../../schema/mailer.schema';
import type { MailerSchema } from '../../schema/mailer.schema';
type Config = z.infer<typeof MailerSchema>;

View File

@@ -1,7 +1,7 @@
import { z } from 'zod';
const MAILER_PROVIDER = z
.enum(['nodemailer', 'cloudflare', 'resend'])
.enum(['nodemailer', 'resend'])
.default('nodemailer')
.parse(process.env.MAILER_PROVIDER);
@@ -13,9 +13,6 @@ export async function getMailer() {
case 'nodemailer':
return getNodemailer();
case 'cloudflare':
return getCloudflareMailer();
case 'resend':
return getResendMailer();
@@ -36,12 +33,6 @@ async function getNodemailer() {
}
}
async function getCloudflareMailer() {
const { CloudflareMailer } = await import('./impl/cloudflare');
return new CloudflareMailer();
}
async function getResendMailer() {
const { ResendMailer } = await import('./impl/resend');