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.
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import type { PageServerLoad, Actions } from './$types.js';
|
|
import { requireAuth } from '$lib/server/middleware/authenticate.js';
|
|
import * as apiTokenService from '$lib/server/services/apiTokenService.js';
|
|
import { createApiTokenSchema } from '$lib/utils/validators.js';
|
|
import { fail } from '@sveltejs/kit';
|
|
|
|
export const load: PageServerLoad = async (event) => {
|
|
const user = requireAuth(event);
|
|
|
|
const tokens = await apiTokenService.listTokens(user.id);
|
|
|
|
return { tokens };
|
|
};
|
|
|
|
export const actions: Actions = {
|
|
create: async (event) => {
|
|
const user = requireAuth(event);
|
|
|
|
const formData = await event.request.formData();
|
|
const name = formData.get('name') as string;
|
|
const scope = formData.get('scope') as string;
|
|
const expiresAt = formData.get('expiresAt') as string;
|
|
|
|
const parsed = createApiTokenSchema.safeParse({
|
|
name,
|
|
scope,
|
|
expiresAt: expiresAt || undefined
|
|
});
|
|
|
|
if (!parsed.success) {
|
|
return fail(400, {
|
|
error: parsed.error.issues.map((i) => i.message).join(', ')
|
|
});
|
|
}
|
|
|
|
try {
|
|
const result = await apiTokenService.generateToken(
|
|
user.id,
|
|
parsed.data.name,
|
|
parsed.data.scope,
|
|
parsed.data.expiresAt ?? undefined
|
|
);
|
|
|
|
return { token: result.token, tokenId: result.id };
|
|
} catch (err) {
|
|
const message = err instanceof Error ? err.message : 'Failed to create token';
|
|
return fail(500, { error: message });
|
|
}
|
|
},
|
|
|
|
revoke: async (event) => {
|
|
const user = requireAuth(event);
|
|
|
|
const formData = await event.request.formData();
|
|
const tokenId = formData.get('tokenId') as string;
|
|
|
|
if (!tokenId) {
|
|
return fail(400, { error: 'Token ID is required' });
|
|
}
|
|
|
|
try {
|
|
await apiTokenService.revokeToken(tokenId, user.id);
|
|
} catch (err) {
|
|
const message = err instanceof Error ? err.message : 'Failed to revoke token';
|
|
return fail(500, { error: message });
|
|
}
|
|
|
|
return { success: true };
|
|
}
|
|
};
|