- Build complete Next.js CRM for commercial real estate - Add authentication with JWT sessions and role-based access - Add GoHighLevel API integration for contacts, conversations, opportunities - Add AI-powered Control Center with tool calling - Add Setup page with onboarding checklist (/setup) - Add sidebar navigation with Setup menu item - Fix type errors in onboarding API, GHL services, and control center tools - Add Prisma schema with SQLite for local development - Add UI components with clay morphism design system Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
33 lines
963 B
TypeScript
33 lines
963 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { z } from 'zod';
|
|
import { getSession, isSuperAdmin } from '@/lib/auth';
|
|
import { settingsService } from '@/lib/settings';
|
|
import { Role } from '@/types';
|
|
|
|
const testSchema = z.object({
|
|
service: z.enum(['ghl', 'stripe']),
|
|
});
|
|
|
|
export async function POST(request: NextRequest) {
|
|
const session = await getSession();
|
|
if (!session || !isSuperAdmin(session.user.role as Role)) {
|
|
return NextResponse.json({ error: 'Forbidden' }, { status: 403 });
|
|
}
|
|
|
|
try {
|
|
const body = await request.json();
|
|
const { service } = testSchema.parse(body);
|
|
|
|
let result;
|
|
if (service === 'ghl') {
|
|
result = await settingsService.testGHLConnection();
|
|
} else if (service === 'stripe') {
|
|
result = await settingsService.testStripeConnection();
|
|
}
|
|
|
|
return NextResponse.json(result);
|
|
} catch (error) {
|
|
return NextResponse.json({ error: 'Test failed' }, { status: 500 });
|
|
}
|
|
}
|