51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { NextResponse } from 'next/server'
|
|
|
|
// This is a simple in-memory store for demo purposes
|
|
// In production, you'd want to use a database
|
|
const waitlist = new Set<string>()
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const { email } = await request.json()
|
|
|
|
if (!email || !email.includes('@')) {
|
|
return NextResponse.json(
|
|
{ error: 'Valid email required' },
|
|
{ status: 400 }
|
|
)
|
|
}
|
|
|
|
if (waitlist.has(email)) {
|
|
return NextResponse.json(
|
|
{ error: 'Already in the network' },
|
|
{ status: 400 }
|
|
)
|
|
}
|
|
|
|
waitlist.add(email)
|
|
|
|
// In production, you'd save to a database here
|
|
// and potentially send a confirmation email
|
|
console.log('[v0] New waitlist signup:', email)
|
|
console.log('[v0] Total waitlist size:', waitlist.size)
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
message: 'Welcome to the underground',
|
|
})
|
|
} catch (error) {
|
|
console.error('[v0] Waitlist error:', error)
|
|
return NextResponse.json(
|
|
{ error: 'Network error occurred' },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|
|
|
|
// Optional: Add a GET endpoint to check waitlist status (for admin use)
|
|
export async function GET() {
|
|
return NextResponse.json({
|
|
count: waitlist.size,
|
|
})
|
|
}
|