johnandersen777.bsky.social/knotless
git that lives in your Atmosphere account
Forked from chadtmiller.com/knotless
0
0
import type * as getUsage from '#lib/lexicons/dev/knotless/getUsage.ts';
import type * as listReports from '#lib/lexicons/dev/knotless/listReports.ts';
import type { PageLoad } from './$types';
import { xrpc } from '#lib/data.ts';
/** How many days of use the page shows, today the last. */
const DAYS = 14;
/**
* For this appview's operators: the reports it was sent, newest first, and
* how it was used day by day. Nothing for anyone else.
*/
export const load: PageLoad = async (event) => {
const { viewer } = await event.parent();
if (!viewer?.admin)
return {
admin: false,
actor: viewer?.actor ?? null,
login: viewer?.login ?? false,
reports: null,
usage: null
};
const [reports, usage] = await Promise.all([
xrpc<typeof listReports.main>(event, 'dev.knotless.listReports', { limit: 50 }, true),
xrpc<typeof getUsage.main>(event, 'dev.knotless.getUsage', { days: DAYS }, true)
]);
return { admin: true, actor: viewer.actor ?? null, login: true, reports, usage };
};