Add 'vercel-email' package and update Cloudflare mailer implementation
The 'vercel-email' package was added as a dependency to facilitate sending emails using Cloudflare workers. The CloudflareMailer class has been updated to leverage 'vercel-email' for sending emails. Instructions for setting up the 'vercel-email' package with the Cloudflare provider were added to the README.md file. The
This commit is contained in:
@@ -40,4 +40,6 @@ async function sendEmail() {
|
||||
text: 'Hello, World!'
|
||||
});
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
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.
|
||||
@@ -13,7 +13,8 @@
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"nodemailer": "^6.9.13"
|
||||
"nodemailer": "^6.9.13",
|
||||
"vercel-email": "0.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/eslint-config": "workspace:*",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'server-only';
|
||||
|
||||
import Email from 'vercel-email';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { Mailer } from '../../mailer';
|
||||
@@ -8,15 +8,23 @@ import { MailerSchema } from '../../schema/mailer.schema';
|
||||
type Config = z.infer<typeof MailerSchema>;
|
||||
|
||||
/**
|
||||
* A class representing a mailer using Cloudflare's Workers.
|
||||
* 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) {
|
||||
// make lint happy for now
|
||||
await Promise.resolve();
|
||||
const schema = {
|
||||
to: config.to,
|
||||
from: config.from,
|
||||
subject: config.subject,
|
||||
};
|
||||
|
||||
console.log('Sending email with Cloudflare Workers', config);
|
||||
throw new Error('Not implemented');
|
||||
const content =
|
||||
'text' in config ? { text: config.text } : { html: config.html };
|
||||
|
||||
return Email.send({
|
||||
...schema,
|
||||
...content,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user