File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { NextResponse } from "next/server"
2
+
3
+ import { db } from "@/drizzle.config"
4
+ import { waitlist } from "@/app/api/schema"
5
+
6
+ export async function GET ( ) {
7
+ try {
8
+ const allWaitlist = await db . select ( ) . from ( waitlist )
9
+ return NextResponse . json ( allWaitlist , { status : 200 } )
10
+ } catch ( error ) {
11
+ console . error ( "Error fetching waitlist:" , error )
12
+ return NextResponse . json (
13
+ { error : "Failed to fetch waitlist" } ,
14
+ { status : 500 }
15
+ )
16
+ }
17
+ }
18
+
19
+ export async function POST ( request : Request ) {
20
+ try {
21
+ const body = await request . json ( )
22
+ const { email } = body
23
+
24
+ await db . insert ( waitlist ) . values ( { email } )
25
+
26
+ return NextResponse . json ( { message : "Joined waitlist!" } , { status : 200 } )
27
+ } catch ( error ) {
28
+ console . error ( "Error processing request:" , error )
29
+ return NextResponse . json (
30
+ {
31
+ message : "Something went wrong!" ,
32
+ error : "Failed to process request" ,
33
+ } ,
34
+ { status : 400 }
35
+ )
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments