feat(mvp): phase 4 - app registry & healthcheck

Add app CRUD API endpoints, healthcheck service with node-cron scheduler,
icon resolver (Lucide, Simple Icons, CDN, uploads), app management UI
with Superforms, health badge component, and Docker health endpoint.
This commit is contained in:
2026-03-24 20:53:50 +03:00
parent 2c001df322
commit 4d941f566f
17 changed files with 962 additions and 21 deletions
+46
View File
@@ -0,0 +1,46 @@
import type { Actions, PageServerLoad } from './$types.js';
import { superValidate, setError } from 'sveltekit-superforms';
import { zod } from 'sveltekit-superforms/adapters';
import { fail } from '@sveltejs/kit';
import { requireAuth } from '$lib/server/middleware/authenticate.js';
import * as appService from '$lib/server/services/appService.js';
import { createAppSchema } from '$lib/utils/validators.js';
export const load: PageServerLoad = async (event) => {
requireAuth(event);
const category = event.url.searchParams.get('category') ?? undefined;
const search = event.url.searchParams.get('search') ?? undefined;
const [apps, categories, form] = await Promise.all([
appService.findAll({ category, search }),
appService.getCategories(),
superValidate(zod(createAppSchema))
]);
return { apps, categories, form };
};
export const actions: Actions = {
create: async (event) => {
const user = requireAuth(event);
const form = await superValidate(event.request, zod(createAppSchema));
if (!form.valid) {
return fail(400, { form });
}
try {
await appService.create({
...form.data,
createdById: user.id
});
} catch (err) {
const message = err instanceof Error ? err.message : 'Failed to create app';
return setError(form, '', message);
}
return { form };
}
};
+67
View File
@@ -0,0 +1,67 @@
<script lang="ts">
import type { PageData } from './$types.js';
import AppCard from '$lib/components/app/AppCard.svelte';
import AppForm from '$lib/components/app/AppForm.svelte';
let { data }: { data: PageData } = $props();
let showForm = $state(false);
</script>
<svelte:head>
<title>Apps — Web App Launcher</title>
</svelte:head>
<main class="min-h-screen bg-background p-6 text-foreground">
<div class="mx-auto max-w-6xl">
<div class="mb-6 flex items-center justify-between">
<h1 class="text-2xl font-bold text-card-foreground">App Registry</h1>
<button
type="button"
onclick={() => (showForm = !showForm)}
class="rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring"
>
{showForm ? 'Cancel' : 'Add App'}
</button>
</div>
{#if showForm}
<div class="mb-6 rounded-lg border border-border bg-card p-6">
<h2 class="mb-4 text-lg font-semibold text-card-foreground">New App</h2>
<AppForm form={data.form} action="?/create" />
</div>
{/if}
{#if data.categories.length > 0}
<div class="mb-4 flex flex-wrap gap-2">
<a
href="/apps"
class="rounded-full border border-border px-3 py-1 text-sm text-muted-foreground hover:bg-accent"
>
All
</a>
{#each data.categories as category}
<a
href="/apps?category={encodeURIComponent(category)}"
class="rounded-full border border-border px-3 py-1 text-sm text-muted-foreground hover:bg-accent"
>
{category}
</a>
{/each}
</div>
{/if}
{#if data.apps.length === 0}
<div class="flex flex-col items-center justify-center py-16 text-muted-foreground">
<p class="text-lg">No apps registered yet.</p>
<p class="mt-1 text-sm">Click "Add App" to register your first application.</p>
</div>
{:else}
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
{#each data.apps as app (app.id)}
<AppCard {app} />
{/each}
</div>
{/if}
</div>
</main>