mirror of
https://github.com/bretzel-app/crumbs.git
synced 2026-10-12 20:06:57 +02:00
- 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>
22 lines
720 B
TypeScript
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 });
|
|
};
|