26 lines
773 B
TypeScript
26 lines
773 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { getAuthService } from '@/lib/auth';
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const body = await request.json();
|
|
const { email, password, displayName } = body;
|
|
|
|
if (!email || !password || !displayName) {
|
|
return NextResponse.json(
|
|
{ error: 'Email, password, and display name are required' },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
const authService = getAuthService();
|
|
const session = await authService.signupWithEmail({ email, password, displayName });
|
|
|
|
return NextResponse.json({ success: true, session });
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ error: error instanceof Error ? error.message : 'Signup failed' },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
} |