Skip to content

Commit 3d50caf

Browse files
authored
feat: implement resend rest email adapter (#5916)
1 parent 4d7ef58 commit 3d50caf

20 files changed

+655
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"build:db-mongodb": "turbo build --filter db-mongodb",
1414
"build:db-postgres": "turbo build --filter db-postgres",
1515
"build:email-nodemailer": "turbo build --filter email-nodemailer",
16+
"build:email-resend-rest": "turbo build --filter email-resend-rest",
1617
"build:eslint-config-payload": "turbo build --filter eslint-config-payload",
1718
"build:graphql": "turbo build --filter graphql",
1819
"build:live-preview": "turbo build --filter live-preview",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.tmp
2+
**/.git
3+
**/.hg
4+
**/.pnp.*
5+
**/.svn
6+
**/.yarn/**
7+
**/build
8+
**/dist/**
9+
**/node_modules
10+
**/temp
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/** @type {import('eslint').Linter.Config} */
2+
module.exports = {
3+
parserOptions: {
4+
project: ['./tsconfig.json'],
5+
tsconfigRootDir: __dirname,
6+
},
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.tmp
2+
**/.git
3+
**/.hg
4+
**/.pnp.*
5+
**/.svn
6+
**/.yarn/**
7+
**/build
8+
**/dist/**
9+
**/node_modules
10+
**/temp

packages/email-resend-rest/.swcrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://json.schemastore.org/swcrc",
3+
"sourceMaps": true,
4+
"jsc": {
5+
"target": "esnext",
6+
"parser": {
7+
"syntax": "typescript",
8+
"tsx": true,
9+
"dts": true
10+
}
11+
},
12+
"module": {
13+
"type": "es6"
14+
}
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "https://json.schemastore.org/swcrc",
3+
"sourceMaps": true,
4+
"exclude": [
5+
"/**/mocks",
6+
"/**/*.spec.ts"
7+
],
8+
"jsc": {
9+
"target": "esnext",
10+
"parser": {
11+
"syntax": "typescript",
12+
"tsx": true,
13+
"dts": true
14+
}
15+
},
16+
"module": {
17+
"type": "es6"
18+
}
19+
}

packages/email-resend-rest/LICENSE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2018-2022 Payload CMS, LLC <info@payloadcms.com>
4+
Portions Copyright (c) Meta Platforms, Inc. and affiliates.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

packages/email-resend-rest/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Resend REST Email Adapter
2+
3+
This adapter allows you to send emails using the [Resend](https://resend.com) REST API.
4+
5+
## Installation
6+
7+
```sh
8+
pnpm add @payloadcms/email-resend-rest`
9+
```
10+
11+
## Usage
12+
13+
- Sign up for a [Resend](https://resend.com) account
14+
- Set up a domain
15+
- Create an API key
16+
- Set API key as RESEND_API_KEY environment variable
17+
- Configure your Payload config
18+
19+
```ts
20+
// payload.config.js
21+
import { resendAdapter } from '@payloadcms/email-resend-rest'
22+
23+
export default buildConfig({
24+
email: resendAdapter({
25+
defaultFromAddress: 'dev@payloadcms.com',
26+
defaultFromName: 'Payload CMS',
27+
apiKey: process.env.RESEND_API_KEY || '',
28+
}),
29+
})
30+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/** @type {import('jest').Config} */
2+
const customJestConfig = {
3+
rootDir: '.',
4+
extensionsToTreatAsEsm: ['.ts', '.tsx'],
5+
moduleNameMapper: {
6+
'^(\\.{1,2}/.*)\\.js$': '$1',
7+
},
8+
testEnvironment: 'node',
9+
testMatch: ['<rootDir>/**/*spec.ts'],
10+
testTimeout: 10000,
11+
transform: {
12+
'^.+\\.(t|j)sx?$': ['@swc/jest'],
13+
},
14+
verbose: true,
15+
}
16+
17+
export default customJestConfig
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "@payloadcms/email-resend-rest",
3+
"version": "0.0.0",
4+
"description": "Payload Resend Email Adapter",
5+
"homepage": "https://payloadcms.com",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/payloadcms/payload.git",
9+
"directory": "packages/email-resend-rest"
10+
},
11+
"license": "MIT",
12+
"author": "Payload CMS, Inc.",
13+
"type": "module",
14+
"exports": {
15+
".": {
16+
"import": "./src/index.ts",
17+
"require": "./src/index.ts",
18+
"types": "./src/index.ts"
19+
}
20+
},
21+
"main": "./src/index.ts",
22+
"types": "./src/index.ts",
23+
"files": [
24+
"dist"
25+
],
26+
"scripts": {
27+
"build": "pnpm build:swc && pnpm build:types",
28+
"build:swc": "swc ./src -d ./dist --config-file .swcrc-build",
29+
"build:types": "tsc --emitDeclarationOnly --outDir dist",
30+
"clean": "rimraf {dist,*.tsbuildinfo}",
31+
"prepublishOnly": "pnpm clean && pnpm turbo build",
32+
"test": "jest"
33+
},
34+
"devDependencies": {
35+
"@types/jest": "29.5.12",
36+
"jest": "^29.7.0",
37+
"payload": "workspace:*"
38+
},
39+
"peerDependencies": {
40+
"payload": "workspace:*"
41+
},
42+
"engines": {
43+
"node": ">=18.20.2"
44+
},
45+
"publishConfig": {
46+
"exports": {
47+
".": {
48+
"import": "./dist/index.js",
49+
"require": "./dist/index.js",
50+
"types": "./dist/index.d.ts"
51+
}
52+
},
53+
"main": "./dist/index.js",
54+
"registry": "https://registry.npmjs.org/",
55+
"types": "./dist/index.d.ts"
56+
}
57+
}

0 commit comments

Comments
 (0)