Add public profiles and cosmetic shop
All checks were successful
Deploy MineGeo to Dokploy / deploy (push) Successful in 7m10s

This commit is contained in:
2026-10-15 17:30:10 +05:00
parent 44e62cff2f
commit c541cc09b4
28 changed files with 1359 additions and 45 deletions

41
lib/public-profile.ts Normal file
View File

@@ -0,0 +1,41 @@
import "server-only";
import { z } from "zod";
import { admin } from "./supabase";
const uuidSchema = z.string().uuid();
export async function publicProfile(userId: string) {
const validId = uuidSchema.safeParse(userId);
if (!validId.success) return null;
const result = await admin()
.from("profiles")
.select(
"id,display_name,bio,avatar_path,profile_effect,name_glow,glow_color,role,bug_finder,custom_prefix,custom_prefix_icon,created_at",
)
.eq("id", validId.data)
.eq("account_status", "active")
.maybeSingle();
if (result.error) throw new Error(result.error.message);
if (!result.data) return null;
const [games, maps] = await Promise.all([
admin()
.from("game_sessions")
.select("id", { count: "exact", head: true })
.eq("owner_id", validId.data)
.eq("current_round", 5),
admin()
.from("datasets")
.select("id", { count: "exact", head: true })
.eq("owner_id", validId.data)
.eq("state", "published"),
]);
if (games.error) throw new Error(games.error.message);
if (maps.error) throw new Error(maps.error.message);
return {
...result.data,
completedGames: games.count ?? 0,
publishedMaps: maps.count ?? 0,
};
}