Dynamic Branding, Instance name and description on log in sign up page.

This commit is contained in:
Christopher
2026-01-22 12:34:15 -08:00
parent 3c904997fa
commit 8300001e75
3 changed files with 164 additions and 16 deletions
+30
View File
@@ -0,0 +1,30 @@
import { NextRequest, NextResponse } from 'next/server';
import { db, users } from '@/db';
import { eq } from 'drizzle-orm';
export async function GET(req: NextRequest) {
try {
const { searchParams } = new URL(req.url);
const handle = searchParams.get('handle')?.toLowerCase().trim();
if (!handle || handle.length < 3) {
return NextResponse.json({ available: false, error: 'Handle too short' });
}
if (!/^[a-zA-Z0-9_]+$/.test(handle)) {
return NextResponse.json({ available: false, error: 'Invalid characters' });
}
const existingUser = await db.query.users.findFirst({
where: eq(users.handle, handle),
});
return NextResponse.json({
available: !existingUser,
handle
});
} catch (error) {
console.error('Check handle error:', error);
return NextResponse.json({ error: 'Failed to check handle' }, { status: 500 });
}
}