- Dashboard Overview with real-time status display - Live Log Viewer (scrollable, filterable) - Config Editor with JSON syntax highlighting - Model Switcher for provider management - Provider Manager for API key configuration - Quick Actions for common tasks - API Routes: status, logs, config, actions, models, providers Tech Stack: - Next.js 14 (App Router) - TypeScript - Tailwind CSS - shadcn/ui components - CodeMirror for JSON editing - Docker support with docker-compose
36 lines
873 B
TypeScript
36 lines
873 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { getProviders, setProviderApiKey } from '@/lib/openclaw';
|
|
|
|
export async function GET() {
|
|
try {
|
|
const providers = await getProviders();
|
|
return NextResponse.json({ providers });
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ error: (error as Error).message },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const { providerId, apiKey } = await request.json();
|
|
|
|
if (!providerId || !apiKey) {
|
|
return NextResponse.json(
|
|
{ error: 'providerId and apiKey are required' },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
const result = await setProviderApiKey(providerId, apiKey);
|
|
return NextResponse.json(result);
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ error: (error as Error).message },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|