mirror of
https://gitbruv.vercel.app/api/git/bruv/gitbruv.git
synced 2025-12-20 23:24:09 +01:00
fix
This commit is contained in:
parent
2483a758c8
commit
698cf2bcd9
4 changed files with 27 additions and 48 deletions
|
|
@ -6,6 +6,7 @@ import { CloneUrl } from "@/components/clone-url";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { GitBranch, Lock, Globe, FileCode } from "lucide-react";
|
import { GitBranch, Lock, Globe, FileCode } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { getPublicServerUrl } from "@/lib/utils";
|
||||||
|
|
||||||
export default async function RepoPage({ params }: { params: Promise<{ username: string; repo: string }> }) {
|
export default async function RepoPage({ params }: { params: Promise<{ username: string; repo: string }> }) {
|
||||||
const { username, repo: repoName } = await params;
|
const { username, repo: repoName } = await params;
|
||||||
|
|
@ -95,7 +96,7 @@ export default async function RepoPage({ params }: { params: Promise<{ username:
|
||||||
}
|
}
|
||||||
|
|
||||||
function EmptyRepoGuide({ username, repoName }: { username: string; repoName: string }) {
|
function EmptyRepoGuide({ username, repoName }: { username: string; repoName: string }) {
|
||||||
const cloneUrl = `${process.env.NEXT_PUBLIC_APP_URL || "http://localhost:3000"}/api/git/${username}/${repoName}.git`;
|
const cloneUrl = `${getPublicServerUrl()}/api/git/${username}/${repoName}.git`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-6 space-y-6">
|
<div className="p-6 space-y-6">
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,14 @@ import { useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Check, Copy, ChevronDown } from "lucide-react";
|
import { Check, Copy, ChevronDown } from "lucide-react";
|
||||||
import {
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
||||||
DropdownMenu,
|
import { getPublicServerUrl } from "@/lib/utils";
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from "@/components/ui/dropdown-menu";
|
|
||||||
|
|
||||||
export function CloneUrl({
|
export function CloneUrl({ username, repoName }: { username: string; repoName: string }) {
|
||||||
username,
|
|
||||||
repoName,
|
|
||||||
}: {
|
|
||||||
username: string;
|
|
||||||
repoName: string;
|
|
||||||
}) {
|
|
||||||
const [copied, setCopied] = useState(false);
|
const [copied, setCopied] = useState(false);
|
||||||
const [protocol, setProtocol] = useState<"https" | "ssh">("https");
|
const [protocol, setProtocol] = useState<"https" | "ssh">("https");
|
||||||
|
|
||||||
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || "http://localhost:3000";
|
const baseUrl = getPublicServerUrl();
|
||||||
const httpsUrl = `${baseUrl}/api/git/${username}/${repoName}.git`;
|
const httpsUrl = `${baseUrl}/api/git/${username}/${repoName}.git`;
|
||||||
const sshUrl = `git@gitbruv.local:${username}/${repoName}.git`;
|
const sshUrl = `git@gitbruv.local:${username}/${repoName}.git`;
|
||||||
|
|
||||||
|
|
@ -43,34 +33,16 @@ export function CloneUrl({
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
<DropdownMenuItem onClick={() => setProtocol("https")}>
|
<DropdownMenuItem onClick={() => setProtocol("https")}>HTTPS</DropdownMenuItem>
|
||||||
HTTPS
|
<DropdownMenuItem onClick={() => setProtocol("ssh")}>SSH</DropdownMenuItem>
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onClick={() => setProtocol("ssh")}>
|
|
||||||
SSH
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
<div className="relative flex-1 min-w-[280px]">
|
<div className="relative flex-1 min-w-[280px]">
|
||||||
<Input
|
<Input value={url} readOnly className="pr-10 font-mono text-xs bg-muted" />
|
||||||
value={url}
|
<Button variant="ghost" size="icon" className="absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7" onClick={copyToClipboard}>
|
||||||
readOnly
|
{copied ? <Check className="h-3.5 w-3.5 text-primary" /> : <Copy className="h-3.5 w-3.5" />}
|
||||||
className="pr-10 font-mono text-xs bg-muted"
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7"
|
|
||||||
onClick={copyToClipboard}
|
|
||||||
>
|
|
||||||
{copied ? (
|
|
||||||
<Check className="h-3.5 w-3.5 text-primary" />
|
|
||||||
) : (
|
|
||||||
<Copy className="h-3.5 w-3.5" />
|
|
||||||
)}
|
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
import { createAuthClient } from "better-auth/react";
|
import { createAuthClient } from "better-auth/react";
|
||||||
|
import { getPublicServerUrl } from "./utils";
|
||||||
|
|
||||||
export const authClient = createAuthClient({
|
export const authClient = createAuthClient({
|
||||||
baseURL: process.env.NEXT_PUBLIC_APP_URL || "http://localhost:3000",
|
baseURL: getPublicServerUrl(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const { signIn, signOut, useSession } = authClient;
|
export const { signIn, signOut, useSession } = authClient;
|
||||||
|
|
||||||
export async function signUpWithUsername(data: {
|
export async function signUpWithUsername(data: { email: string; password: string; name: string; username: string }) {
|
||||||
email: string;
|
|
||||||
password: string;
|
|
||||||
name: string;
|
|
||||||
username: string;
|
|
||||||
}) {
|
|
||||||
return authClient.signUp.email(data as Parameters<typeof authClient.signUp.email>[0]);
|
return authClient.signUp.email(data as Parameters<typeof authClient.signUp.email>[0]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
lib/utils.ts
16
lib/utils.ts
|
|
@ -1,6 +1,16 @@
|
||||||
import { clsx, type ClassValue } from "clsx"
|
import { clsx, type ClassValue } from "clsx";
|
||||||
import { twMerge } from "tailwind-merge"
|
import { twMerge } from "tailwind-merge";
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs))
|
return twMerge(clsx(inputs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getPublicServerUrl = () => {
|
||||||
|
if (process.env.NEXT_PUBLIC_VERCEL_ENV === "production") {
|
||||||
|
return `https://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}`;
|
||||||
|
} else if (process.env.NEXT_PUBLIC_VERCEL_ENV === "preview") {
|
||||||
|
return `https://${process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL}`;
|
||||||
|
} else {
|
||||||
|
return `http://localhost:3000`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue