diff --git a/src/app/api/waitlist/route.ts b/src/app/api/waitlist/route.ts index 20d69e4..fd22071 100644 --- a/src/app/api/waitlist/route.ts +++ b/src/app/api/waitlist/route.ts @@ -1,5 +1,4 @@ import { NextRequest, NextResponse } from 'next/server'; -import nodemailer from 'nodemailer'; interface WaitlistEntry { email: string; @@ -8,16 +7,8 @@ interface WaitlistEntry { createdAt: string; } -const transporter = nodemailer.createTransport({ - host: process.env.SMTP_HOST || 'smtp.gmail.com', - port: parseInt(process.env.SMTP_PORT || '587'), - secure: process.env.SMTP_SECURE === 'true', - auth: { - user: process.env.SMTP_USER, - pass: process.env.SMTP_PASSWORD, - }, -}); - +// In-memory storage for demonstration +// In production, replace with actual database (MongoDB, PostgreSQL, etc.) const waitlistEntries: WaitlistEntry[] = []; export async function POST(request: NextRequest) { @@ -26,17 +17,17 @@ export async function POST(request: NextRequest) { const { email, instagram, tiktok } = body; // Validate email - if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) { + if (!email || typeof email !== 'string' || !email.includes('@')) { return NextResponse.json( - { error: 'Invalid email address' }, + { error: 'Valid email is required' }, { status: 400 } ); } - // Check if email already exists + // Check for duplicate email if (waitlistEntries.some(entry => entry.email === email)) { return NextResponse.json( - { error: 'Email already on waitlist' }, + { error: 'Email already registered' }, { status: 409 } ); } @@ -46,79 +37,50 @@ export async function POST(request: NextRequest) { email, instagram: instagram || undefined, tiktok: tiktok || undefined, - createdAt: new Date().toISOString(), + createdAt: new Date().toISOString() }; + // Add to in-memory storage waitlistEntries.push(entry); - // Send confirmation email to user - const userEmailHtml = ` -
Hi ${email.split('@')[0]},
-Thank you for joining the Clearance waitlist! We're excited to have you on board.
-We'll be reaching out soon with early access to our platform. In the meantime, here's what you can expect:
-If you have any questions, feel free to reply to this email.
-Best regards,
The Clearance Team
Email: ${email}
-Instagram: ${instagram || 'Not provided'}
-TikTok: ${tiktok || 'Not provided'}
-Submitted: ${new Date().toLocaleString()}
-