AI tracker: /trackers/ai with public news, owner-only bots and usage; ai schema (news_items, bot_status, usage_entries); idempotent import scripts; preflight ai grants check
Deploy production / deploy (push) Has been cancelled

This commit is contained in:
stan committed 2026-10-25 23:58:39 +00:00
1 parent 9b21220280
commit cf0fec973c
24 files changed
+38866 -3

No files matched your search

@@ -0,0 +1,28 @@
import { requireOwner } from '#lib/server/owner.js';
import { addUsage, deleteUsage, loadUsage } from '#lib/server/ai-tracker.js';
import { fail } from '@sveltejs/kit';
import type { Actions, PageServerLoad } from './$types';
// Owner only: dated usage numbers per provider. Actions don't run the load, so each
// action checks the owner again (hooks.server.ts also 404s this path for everyone else).
export const load: PageServerLoad = async (event) => {
requireOwner(event);
event.setHeaders({ 'cache-control': 'private, no-store' });
return {
entries: await loadUsage(),
seo: { title: 'AI tracker · usage', description: 'My AI usage.', index: false }
};
};
export const actions: Actions = {
add: async (event) => {
requireOwner(event);
const r = await addUsage(await event.request.formData());
return r.ok ? { saved: true } : fail(400, { message: r.message });
},
delete: async (event) => {
requireOwner(event);
const r = await deleteUsage(await event.request.formData());
return r.ok ? { deleted: true } : fail(400, { message: r.message });
}
};