import { error } from "@sveltejs/kit";
import { getUser } from "$lib/database";

/** @type {import('./$types').PageServerLoad} */
export async function load({ params }) {
	const user = await getUser({ _id: Number(params.id) }, { username: true, currency: true, joinDate: true, lastOnline: true, rank: true, activity: true, bio: true });
	if (!user) throw error(404, "That user doesn't exist");

	return { profile: user };
}
