Function bodies 164 total
TooltipTrigger function · typescript · L27-L31 (5 LOC)src/components/ui/tooltip.tsx
function TooltipTrigger({
...props
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
}TooltipContent function · typescript · L33-L55 (23 LOC)src/components/ui/tooltip.tsx
function TooltipContent({
className,
sideOffset = 0,
children,
...props
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
return (
<TooltipPrimitive.Portal>
<TooltipPrimitive.Content
data-slot="tooltip-content"
sideOffset={sideOffset}
className={cn(
"bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
className
)}
{...props}
>
{children}
<TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
</TooltipPrimitive.Content>
</TogetPlanById function · typescript · L117-L119 (3 LOC)src/config/plans.ts
export function getPlanById(planId: PlanId): PlanConfig {
return plans[planId];
}getPlanByPaddlePriceId function · typescript · L121-L129 (9 LOC)src/config/plans.ts
export function getPlanByPaddlePriceId(
priceId: string
): PlanConfig | undefined {
return Object.values(plans).find(
(plan) =>
plan.paddlePriceIdMonthly === priceId ||
plan.paddlePriceIdAnnual === priceId
);
}getMonthlyUsage function · typescript · L4-L27 (24 LOC)src/lib/ai/credits.ts
export async function getMonthlyUsage(userId: string) {
const supabase = await createClient();
const now = new Date();
const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
const { data, error } = await supabase
.from("ai_usage")
.select("credits_used, feature")
.eq("user_id", userId)
.gte("created_at", startOfMonth.toISOString());
if (error) throw error;
const total = data?.reduce((sum, row) => sum + row.credits_used, 0) ?? 0;
const byFeature = data?.reduce(
(acc, row) => {
acc[row.feature] = (acc[row.feature] || 0) + row.credits_used;
return acc;
},
{} as Record<string, number>
);
return { total, byFeature };
}checkCredits function · typescript · L29-L32 (4 LOC)src/lib/ai/credits.ts
export async function checkCredits(
userId: string,
planId: PlanId
): Promise<{ allowed: boolean; remaining: number; limit: number }> {deductCredit function · typescript · L50-L66 (17 LOC)src/lib/ai/credits.ts
export async function deductCredit(
userId: string,
businessId: string,
feature: string,
credits: number = 1
) {
const supabase = await createClient();
const { error } = await supabase.from("ai_usage").insert({
user_id: userId,
business_id: businessId,
feature,
credits_used: credits,
});
if (error) throw error;
}Repobility — the code-quality scanner for AI-generated software · https://repobility.com
getPaddle function · typescript · L5-L15 (11 LOC)src/lib/paddle.ts
export function getPaddle(): Paddle {
if (!_paddle) {
_paddle = new Paddle(process.env.PADDLE_API_KEY!, {
environment:
process.env.PADDLE_ENV === "sandbox"
? Environment.sandbox
: Environment.production,
});
}
return _paddle;
}createAdminClient function · typescript · L3-L9 (7 LOC)src/lib/supabase/admin.ts
export function createAdminClient() {
return createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.SUPABASE_SERVICE_ROLE_KEY!,
{ auth: { autoRefreshToken: false, persistSession: false } }
);
}createClient function · typescript · L5-L19 (15 LOC)src/lib/supabase/client.ts
export function createClient() {
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
if (!supabaseUrl || !supabaseKey) {
// Return a dummy client during build/prerender - this code path
// is only hit during static generation, never at runtime
return createBrowserClient(
"https://placeholder.supabase.co",
"placeholder-key"
);
}
return createBrowserClient(supabaseUrl, supabaseKey);
}updateSession function · typescript · L4-L69 (66 LOC)src/lib/supabase/middleware.ts
export async function updateSession(request: NextRequest) {
let supabaseResponse = NextResponse.next({ request });
const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
getAll() {
return request.cookies.getAll();
},
setAll(cookiesToSet) {
cookiesToSet.forEach(({ name, value, options }) =>
request.cookies.set(name, value)
);
supabaseResponse = NextResponse.next({ request });
cookiesToSet.forEach(({ name, value, options }) =>
supabaseResponse.cookies.set(name, value, options)
);
},
},
}
);
const {
data: { user },
} = await supabase.auth.getUser();
// Protected routes
const isAuthPage =
request.nextUrl.pathname.startsWith("/login") ||
request.nextUrl.pathname.startsWith("/signup") ||
request.nextUrl.pathname.startsWith("/forgot-password"createClient function · typescript · L4-L28 (25 LOC)src/lib/supabase/server.ts
export async function createClient() {
const cookieStore = await cookies();
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
getAll() {
return cookieStore.getAll();
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) =>
cookieStore.set(name, value, options)
);
} catch {
// The `setAll` method was called from a Server Component.
// This can be ignored if you have middleware refreshing user sessions.
}
},
},
}
);
}cn function · typescript · L4-L6 (3 LOC)src/lib/utils.ts
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}middleware function · typescript · L4-L6 (3 LOC)src/middleware.ts
export async function middleware(request: NextRequest) {
return await updateSession(request);
}‹ prevpage 4 / 4