1c0a7cb850
Phase 4 — New Widget Types: - Clock/Weather, System Stats, RSS/Feed, Calendar, Markdown, Metric/Counter, Link Group, Camera/Stream widgets - Backend services with caching for each data source - Full creation form with dynamic config fields per type Phase 5 — Visual & Styling Enhancements: - Glassmorphism card style (solid/glass/outline) - Board-level themes with per-board hue/saturation - Animated SVG status rings replacing static dots - Card size options (compact/medium/large) - Custom CSS injection (admin + per-board, sanitized) - Wallpaper backgrounds with blur/overlay/parallax Phase 6 — Functional Features: - Favorites bar with drag-and-drop reordering - Recent apps tracking with privacy toggle - Uptime dashboard page (/status, guest-accessible) - Notifications system (Discord/Slack/Telegram/HTTP webhooks) - App tags with filtering in board view - Multi-URL app cards with expandable sub-links - Personal API tokens with scoped permissions - Audit log with retention and admin viewer Phase 7 — Quality of Life: - Onboarding wizard (5-step first-launch setup) - App URL health preview with favicon/title detection - Board templates (4 built-in + custom import/export) - Keyboard shortcut overlay (j/k nav, 1-9 boards, ? help) 212 files changed, 15641 insertions, 980 deletions. Build, lint, type check, and 222 tests all pass.
76 lines
1.8 KiB
TypeScript
76 lines
1.8 KiB
TypeScript
import { json } from '@sveltejs/kit';
|
|
import { z } from 'zod';
|
|
import type { RequestHandler } from './$types';
|
|
import { requireAdmin } from '$lib/server/middleware/authorize.js';
|
|
import { create } from '$lib/server/services/appService.js';
|
|
import { success, error } from '$lib/server/utils/response.js';
|
|
|
|
const approveSchema = z.object({
|
|
services: z
|
|
.array(
|
|
z.object({
|
|
name: z.string().min(1),
|
|
url: z.string().url(),
|
|
source: z.enum(['docker', 'traefik']),
|
|
icon: z.string().optional(),
|
|
description: z.string().optional()
|
|
})
|
|
)
|
|
.min(1)
|
|
.max(100)
|
|
});
|
|
|
|
/**
|
|
* POST /api/admin/discover/approve — Approve discovered services and create app entries. Admin only.
|
|
*
|
|
* Body: { services: DiscoveredService[] }
|
|
*/
|
|
export const POST: RequestHandler = async (event) => {
|
|
const user = requireAdmin(event);
|
|
|
|
let rawBody: unknown;
|
|
try {
|
|
rawBody = await event.request.json();
|
|
} catch {
|
|
return json(error('Invalid JSON body'), { status: 400 });
|
|
}
|
|
|
|
const parsed = approveSchema.safeParse(rawBody);
|
|
if (!parsed.success) {
|
|
return json(
|
|
error(`Validation failed: ${parsed.error.issues.map((i) => i.message).join(', ')}`),
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
const body = parsed.data;
|
|
|
|
const created: string[] = [];
|
|
const errors: string[] = [];
|
|
|
|
for (const service of body.services) {
|
|
try {
|
|
const app = await create({
|
|
name: service.name,
|
|
url: service.url,
|
|
icon: service.icon,
|
|
description: service.description ?? `Discovered via ${service.source}`,
|
|
category: 'Discovered',
|
|
healthcheckEnabled: true,
|
|
createdById: user.id
|
|
});
|
|
created.push(app.id);
|
|
} catch (err) {
|
|
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
errors.push(`Failed to create "${service.name}": ${message}`);
|
|
}
|
|
}
|
|
|
|
return json(
|
|
success({
|
|
created: created.length,
|
|
errors
|
|
})
|
|
);
|
|
};
|