website poc
This commit is contained in:
120
apps/website/app/api/signup/route.ts
Normal file
120
apps/website/app/api/signup/route.ts
Normal file
@@ -0,0 +1,120 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { kv } from '@vercel/kv';
|
||||
import { validateEmail, isDisposableEmail } from '@/lib/email-validation';
|
||||
import { checkRateLimit, getClientIp } from '@/lib/rate-limit';
|
||||
|
||||
/**
|
||||
* Email signup storage key
|
||||
*/
|
||||
const SIGNUP_LIST_KEY = 'signups:emails';
|
||||
|
||||
/**
|
||||
* POST /api/signup
|
||||
* Handle email signup submissions
|
||||
*/
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
// Parse request body
|
||||
const body = await request.json();
|
||||
const { email } = body;
|
||||
|
||||
if (!email || typeof email !== 'string') {
|
||||
return NextResponse.json(
|
||||
{ error: 'Email is required' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Validate email format
|
||||
const validation = validateEmail(email);
|
||||
if (!validation.success) {
|
||||
return NextResponse.json(
|
||||
{ error: validation.error },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
const sanitizedEmail = validation.email!;
|
||||
|
||||
// Check for disposable email
|
||||
if (isDisposableEmail(sanitizedEmail)) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Disposable email addresses are not allowed' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Rate limiting
|
||||
const clientIp = getClientIp(request);
|
||||
const rateLimitResult = await checkRateLimit(clientIp);
|
||||
|
||||
if (!rateLimitResult.allowed) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: 'Too many requests. Please try again later.',
|
||||
resetAt: rateLimitResult.resetAt,
|
||||
},
|
||||
{
|
||||
status: 429,
|
||||
headers: {
|
||||
'Retry-After': Math.ceil((rateLimitResult.resetAt - Date.now()) / 1000).toString(),
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Check if email already exists
|
||||
const existingSignup = await kv.hget(SIGNUP_LIST_KEY, sanitizedEmail);
|
||||
|
||||
if (existingSignup) {
|
||||
return NextResponse.json(
|
||||
{ error: 'This email is already registered' },
|
||||
{ status: 409 }
|
||||
);
|
||||
}
|
||||
|
||||
// Store email with timestamp
|
||||
const signupData = {
|
||||
email: sanitizedEmail,
|
||||
timestamp: new Date().toISOString(),
|
||||
ip: clientIp,
|
||||
};
|
||||
|
||||
await kv.hset(SIGNUP_LIST_KEY, {
|
||||
[sanitizedEmail]: JSON.stringify(signupData),
|
||||
});
|
||||
|
||||
// Return success response
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: 'Successfully added to waitlist',
|
||||
},
|
||||
{
|
||||
status: 200,
|
||||
headers: {
|
||||
'X-RateLimit-Remaining': rateLimitResult.remaining.toString(),
|
||||
'X-RateLimit-Reset': rateLimitResult.resetAt.toString(),
|
||||
},
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Signup error:', error);
|
||||
|
||||
return NextResponse.json(
|
||||
{ error: 'An error occurred. Please try again.' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/signup
|
||||
* Return 405 Method Not Allowed
|
||||
*/
|
||||
export async function GET() {
|
||||
return NextResponse.json(
|
||||
{ error: 'Method not allowed' },
|
||||
{ status: 405 }
|
||||
);
|
||||
}
|
||||
27
apps/website/app/globals.css
Normal file
27
apps/website/app/globals.css
Normal file
@@ -0,0 +1,27 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
||||
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
--color-deep-graphite: #0E0F11;
|
||||
--color-iron-gray: #181B1F;
|
||||
--color-charcoal-outline: #22262A;
|
||||
--color-primary-blue: #198CFF;
|
||||
--color-performance-green: #6FE37A;
|
||||
--color-warning-amber: #FFC556;
|
||||
--color-neon-aqua: #43C9E6;
|
||||
}
|
||||
|
||||
body {
|
||||
@apply bg-deep-graphite text-white antialiased;
|
||||
}
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
.animate-spring {
|
||||
transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
|
||||
}
|
||||
}
|
||||
41
apps/website/app/layout.tsx
Normal file
41
apps/website/app/layout.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import type { Metadata } from 'next';
|
||||
import './globals.css';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'GridPilot - iRacing League Racing Platform',
|
||||
description: 'The dedicated home for serious iRacing leagues. Automatic results, standings, team racing, and professional race control.',
|
||||
openGraph: {
|
||||
title: 'GridPilot - iRacing League Racing Platform',
|
||||
description: 'Structure over chaos. The professional platform for iRacing league racing.',
|
||||
type: 'website',
|
||||
},
|
||||
twitter: {
|
||||
card: 'summary_large_image',
|
||||
title: 'GridPilot - iRacing League Racing Platform',
|
||||
description: 'Structure over chaos. The professional platform for iRacing league racing.',
|
||||
},
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<html lang="en" className="scroll-smooth">
|
||||
<body className="antialiased">
|
||||
<header className="fixed top-0 left-0 right-0 z-50 bg-deep-graphite/80 backdrop-blur-sm border-b border-white/5">
|
||||
<div className="max-w-7xl mx-auto px-6 py-4">
|
||||
<div className="flex items-baseline space-x-3">
|
||||
<h1 className="text-2xl font-semibold text-white">GridPilot</h1>
|
||||
<p className="text-sm text-gray-400 font-light">Making league racing less chaotic</p>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div className="pt-16">
|
||||
{children}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
20
apps/website/app/page.tsx
Normal file
20
apps/website/app/page.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { ModeGuard } from '@/components/shared/ModeGuard';
|
||||
import Hero from '@/components/landing/Hero';
|
||||
import FeatureGrid from '@/components/landing/FeatureGrid';
|
||||
import EmailCapture from '@/components/landing/EmailCapture';
|
||||
import FAQ from '@/components/landing/FAQ';
|
||||
import Footer from '@/components/landing/Footer';
|
||||
|
||||
export default function HomePage() {
|
||||
return (
|
||||
<ModeGuard mode="pre-launch">
|
||||
<main className="min-h-screen">
|
||||
<Hero />
|
||||
<FeatureGrid />
|
||||
<EmailCapture />
|
||||
<FAQ />
|
||||
<Footer />
|
||||
</main>
|
||||
</ModeGuard>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user