Files
crumbs-original/src/routes/api/settings/api-keys/+server.ts
T
Frederic CabassutandClaude Opus 4.6 d4ca635346 feat: add Settings subpages with API key management UI
- Settings layout with sidebar nav (Profile, MCP Server, Users)
- Profile page: display name, email, password, sessions
- MCP page: API key CRUD, JSON config with copy button, LLM prompt
- Config auto-populates with actual API key when one is created
- Remove duplicate Settings link from sidebar
- Users page integrated into settings nav (admin only)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 02:03:04 +01:00

22 lines
720 B
TypeScript

import { json } from '@sveltejs/kit';
import type { RequestHandler } from './$types.js';
import { listApiKeys, generateApiKey } from '$lib/server/api-keys.js';
import { getUserId } from '$lib/server/api-utils.js';
export const GET: RequestHandler = async (event) => {
const userId = getUserId(event);
return json(listApiKeys(userId));
};
export const POST: RequestHandler = async ({ request, ...event }) => {
const userId = getUserId(event);
const { name } = await request.json();
if (!name || typeof name !== 'string' || name.trim().length === 0) {
return json({ error: 'Name is required' }, { status: 400 });
}
const result = generateApiKey(name.trim(), userId);
return json(result, { status: 201 });
};