Skip to content

Commit 780f3bc

Browse files
added redis
1 parent 6149199 commit 780f3bc

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

app/api/mail/route.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ const resend = new Resend(process.env.RESEND_API_KEY)
1212
export async function POST(request: NextRequest, response: Response) {
1313
const { email, firstname } = await request.json()
1414

15-
const { data, error } = await resend.emails.send({
16-
from: "Lakshay <[email protected]>",
17-
to: [email],
18-
subject: "Thankyou for waitlisting morph2json!",
19-
html: render(WelcomeTemplate({ userFirstname: firstname})),
20-
})
21-
22-
if (error) {
23-
return Response.json(error)
24-
}
15+
// const { data, error } = await resend.emails.send({
16+
// from: "Lakshay <[email protected]>",
17+
// to: [email],
18+
// subject: "Thankyou for waitlisting morph2json!",
19+
// html: render(WelcomeTemplate({ userFirstname: firstname})),
20+
// })
21+
22+
// if (error) {
23+
// return Response.json(error)
24+
// }
2525

2626
return Response.json({message: "Email sent successfully"})
2727
}

app/config/rateLimit.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Ratelimit } from "@upstash/ratelimit"
2-
import { kv } from "@vercel/kv"
2+
import redis from "./redisDB"
33

44
const ratelimit = new Ratelimit({
5-
redis: kv,
6-
limiter: Ratelimit.slidingWindow(4, "1 m"),
5+
redis: redis,
6+
limiter: Ratelimit.fixedWindow(3, "1 m"),
77
})
88

99
export default ratelimit

app/config/redisDB.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Redis } from "@upstash/redis";
2+
3+
const redis = new Redis({
4+
url: process.env.UPSTASH_REDIS_REST_URL as string,
5+
token: process.env.UPSTASH_REDIS_REST_TOKEN as string,
6+
7+
})
8+
9+
export default redis

bun.lockb

-350 Bytes
Binary file not shown.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@notionhq/client": "^2.2.15",
1414
"@react-email/components": "0.0.19",
1515
"@upstash/ratelimit": "^1.2.1",
16-
"@vercel/kv": "^2.0.0",
16+
"@upstash/redis": "^1.31.6",
1717
"next": "14.2.4",
1818
"react": "^18",
1919
"react-dom": "^18",

0 commit comments

Comments
 (0)