-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
780f3bc
commit 01b065f
Showing
25 changed files
with
995 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,25 +3,54 @@ import { render } from "@react-email/render" | |
import WelcomeTemplate from "../../../emails" | ||
|
||
import { Resend } from "resend" | ||
import { NextRequest } from "next/server" | ||
import { NextRequest, NextResponse } from "next/server" | ||
import { Redis } from "@upstash/redis" | ||
import { Ratelimit } from "@upstash/ratelimit" | ||
|
||
const resend = new Resend(process.env.RESEND_API_KEY) | ||
|
||
const redis = new Redis({ | ||
url: process.env.UPSTASH_REDIS_REST_URL, | ||
token: process.env.UPSTASH_REDIS_REST_TOKEN, | ||
}) | ||
|
||
const ratelimit = new Ratelimit({ | ||
redis, | ||
limiter: Ratelimit.fixedWindow(3, "1 m"), | ||
}) | ||
|
||
export async function POST(request: NextRequest, response: NextResponse) { | ||
const ip = request.ip ?? "127.0.0.1" | ||
|
||
const result = await ratelimit.limit(ip) | ||
|
||
if (!result.success) { | ||
return Response.json( | ||
{ | ||
error: "Too many requests!!", | ||
}, | ||
{ | ||
status: 429, | ||
} | ||
) | ||
} | ||
|
||
export async function POST(request: NextRequest, response: Response) { | ||
const { email, firstname } = await request.json() | ||
|
||
// const { data, error } = await resend.emails.send({ | ||
// from: "Lakshay <[email protected]>", | ||
// to: [email], | ||
// subject: "Thankyou for waitlisting morph2json!", | ||
// html: render(WelcomeTemplate({ userFirstname: firstname})), | ||
// }) | ||
const { data, error } = await resend.emails.send({ | ||
from: "Lakshay <[email protected]>", | ||
to: [email], | ||
subject: "Thankyou for waitlisting morph2json!", | ||
html: render(WelcomeTemplate({ userFirstname: firstname })), | ||
}) | ||
|
||
if (error) { | ||
return NextResponse.json(error) | ||
} | ||
|
||
// if (error) { | ||
// return Response.json(error) | ||
// } | ||
if (!data) { | ||
return NextResponse.json({ message: "Failed to send email" }) | ||
} | ||
|
||
return Response.json({message: "Email sent successfully"}) | ||
return NextResponse.json({ message: "Email sent successfully" }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
import type { Metadata } from "next"; | ||
import { Inter } from "next/font/google"; | ||
import "./globals.css"; | ||
import "./globals.css" | ||
import type { Metadata } from "next" | ||
import { Figtree } from "next/font/google" | ||
import { Toaster } from "@/components/ui/sonner" | ||
|
||
const inter = Inter({ subsets: ["latin"] }); | ||
const FigtreeFont = Figtree({ subsets: ["latin"] }) | ||
|
||
export const metadata: Metadata = { | ||
title: "Create Next App", | ||
description: "Generated by create next app", | ||
}; | ||
title: | ||
"morph2json | Effortlessly Convert your raw data into a well structured JSON", | ||
description: | ||
"Join the waitlist to get early access to morph2json and get notified when it's ready for you to use.", | ||
} | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
children: React.ReactNode | ||
}>) { | ||
return ( | ||
<html lang="en"> | ||
<body className={inter.className}>{children}</body> | ||
<html lang="en" className="dark" suppressHydrationWarning> | ||
<body className={FigtreeFont.className}> | ||
{children} | ||
<Toaster richColors position="top-center" /> | ||
</body> | ||
</html> | ||
); | ||
) | ||
} |
Oops, something went wrong.