MCPcopy Create free account
hub / github.com/cursor/community-plugins / fetchUserProfile

Function fetchUserProfile

apps/cursor/src/data/queries.ts:33–67  ·  view source on GitHub ↗
(slug: string, userId?: string)

Source from the content-addressed store, hash-verified

31import { fetchAllPages } from "@/utils/supabase/pagination";
32
33async function fetchUserProfile(slug: string, userId?: string) {
34 const supabase = await createClient();
35
36 const query = supabase
37 .from("users")
38 .select(
39 "id, name, image, hero, status, bio, work, website, slug, social_x_link, created_at, public, follow_email, is_ambassador, is_following, follower_count, following_count",
40 )
41 .eq("slug", slug);
42
43 if (userId) {
44 query.eq("id", userId);
45 } else {
46 query.eq("public", true);
47 }
48
49 const { data } = await query.single();
50
51 if (!data) {
52 return {
53 data: null,
54 };
55 }
56
57 const isOwner = userId && data.id === userId;
58
59 return {
60 data: {
61 ...data,
62 follow_email: isOwner ? data.follow_email : undefined,
63 following_count: data?.following_count || 0,
64 followers_count: data?.follower_count || 0,
65 },
66 };
67}
68
69async function getPublicUserProfile(slug: string) {
70 "use cache";

Callers 2

getPublicUserProfileFunction · 0.85
getUserProfileFunction · 0.85

Calls 1

createClientFunction · 0.90

Tested by

no test coverage detected