Skip to content

Commit 233bdd1

Browse files
authored
feat: renovate with-attachments-content example (#194)
1 parent 33c4bba commit 233bdd1

File tree

16 files changed

+94
-4253
lines changed

16 files changed

+94
-4253
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
RESEND_API_KEY=re_xxxxxxxxxxxx

with-attachments-content/.eslintrc.js

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
1+
# next.js
2+
.env*
13
.next
2-
node_modules
3-
.env
4-
yarn-error.log
5-
.DS_Store
4+
next-env.d.ts
5+
/.next/
6+
/out/
7+
8+
# dependencies
9+
/node_modules
10+
/.pnp
11+
.pnp.*
612
.yarn/*
713
!.yarn/patches
814
!.yarn/plugins
915
!.yarn/releases
10-
!.yarn/sdks
1116
!.yarn/versions
17+
18+
# env files (can opt-in for committing if needed)
19+
.env*
20+
!.env.example
21+
22+
# misc
23+
.DS_Store
24+
*.pem
25+
26+
# typescript
27+
*.tsbuildinfo
28+
next-env.d.ts

with-attachments-content/.prettierignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

with-attachments-content/.prettierrc.js

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { resend } from '../../../lib/resend';
2+
3+
export async function POST(request: Request) {
4+
const { filename, content } = (await request.json()) as {
5+
filename: string;
6+
content: string;
7+
};
8+
9+
const response = await resend.emails.send({
10+
from: 'Acme <[email protected]>',
11+
12+
subject: 'Receipt for your payment',
13+
html: '<p>Thanks for the payment</p>',
14+
attachments: [
15+
{
16+
filename,
17+
content,
18+
},
19+
],
20+
});
21+
22+
return Response.json(response, {
23+
status: response.error ? 500 : 200,
24+
});
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default function Layout({ children }: { children: React.ReactNode }) {
2+
return (
3+
<html>
4+
<head />
5+
<body>{children}</body>
6+
</html>
7+
);
8+
}

with-attachments-content/src/pages/index.tsx renamed to with-attachments-content/app/page.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import * as React from 'react';
1+
'use client';
22

3-
export const Index: React.FC = () => {
4-
const [content, setContent] = React.useState(null);
5-
const [filename, setFilename] = React.useState('');
3+
import { useState } from 'react';
4+
5+
export default function HomePage() {
6+
const [content, setContent] = useState(null);
7+
const [filename, setFilename] = useState('');
68

79
const onSubmit = async (e: React.FormEvent) => {
810
try {
@@ -20,7 +22,7 @@ export const Index: React.FC = () => {
2022
});
2123

2224
alert('Request sent');
23-
} catch (e) {
25+
} catch {
2426
alert('Something went wrong');
2527
}
2628
};
@@ -56,6 +58,4 @@ export const Index: React.FC = () => {
5658
<input type="submit" value="Send Email" />
5759
</form>
5860
);
59-
};
60-
61-
export default Index;
61+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { Resend } from 'resend';
2+
3+
export const resend = new Resend(process.env.RESEND_API_KEY);

with-attachments-content/next-env.d.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)