Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: remove download api route

Dillion Verma12d8631db0cb
diff --git a/app/api/repo/download/route.tsx b/app/api/repo/download/route.tsx
deleted file mode 100644
index 20f3d26f..00000000
--- a/app/api/repo/download/route.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { NextRequest, NextResponse } from "next/server";
-import { z } from "zod";
-
-import { octokit } from "@/lib/octokit";
-
-const bodySchema = z.object({
- owner: z.string(),
- repo: z.string(),
-});
-
-export async function POST(request: NextRequest) {
- const body = await request.json();
- try {
- const { owner, repo } = bodySchema.parse(body);
- const response = await octokit.request(
- "GET /repos/{owner}/{repo}/zipball",
- {
- owner: owner,
- repo: repo,
- headers: {
- "X-GitHub-Api-Version": "2022-11-28",
- },
- },
- );
- const status = response.status;
- const downloadUrl = response.url;
- return NextResponse.json({ success: true, status, downloadUrl });
- } catch (error: any) {
- return NextResponse.json(
- { success: false, error: error.message },
- { status: 500 },
- );
- }
-}
diff --git a/components/repo-download.tsx b/components/repo-download.tsx
index 2a8ee2fc..b358bd2a 100644
--- a/components/repo-download.tsx
+++ b/components/repo-download.tsx
@@ -1,48 +1,27 @@
"use client";
-import { useState } from "react";
-import Link from "next/link";
import { ArrowRightIcon, Download } from "lucide-react";
+import Link from "next/link";
+import { useState } from "react";
import { toast } from "sonner";
-import { cn } from "@/lib/utils";
-import { Button, buttonVariants } from "@/components/ui/button";
import { Icons } from "@/components/icons";
+import { Button, buttonVariants } from "@/components/ui/button";
+import { cn } from "@/lib/utils";
interface RepoDownloadProps {
- repo: string;
- owner: string;
+ url: string;
free?: boolean;
}
-export default function RepoDownload({
- repo,
- owner,
- free = false,
-}: RepoDownloadProps) {
+export default function RepoDownload({ url, free = false }: RepoDownloadProps) {
const [loading, setLoading] = useState(false);
const handleDownload = async () => {
setLoading(true);
try {
- const response = await fetch(
- `${process.env.NEXT_PUBLIC_APP_URL}/api/repo/download`,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ repo, owner }),
- },
- );
- if (!response.ok) {
- throw new Error(`HTTP error! status: ${response.status}`);
- }
- const data = await response.json();
- const downloadUrl = data.downloadUrl;
- /* window.open(downloadUrl, "_blank"); */
- window.location.href = downloadUrl;
+ window.location.href = url;
} catch (error) {
toast.error("Error occured while downloading. Please try again.");
console.error("error", error);
@@ -73,7 +52,7 @@ export default function RepoDownload({
buttonVariants({
variant: "default",
}),
- "not-prose group relative w-full gap-1",
+ "not-prose group relative w-full gap-1"
)}
>
Buy Now
diff --git a/content/docs/templates/portfolio.mdx b/content/docs/templates/portfolio.mdx
index 2a7672cb..63830fca 100644
--- a/content/docs/templates/portfolio.mdx
+++ b/content/docs/templates/portfolio.mdx
@@ -15,7 +15,10 @@ published: true
className="w-full rounded-xl border shadow-2xl"
/>
<div className="flex w-full flex-col gap-2 sm:flex-row">
- <RepoDownload repo={"portfolio"} owner={"dillionverma"} free />
+ <RepoDownload
+ url="https://codeload.github.com/dillionverma/portfolio/legacy.zip/refs/heads/main"
+ free
+ />
<TemplatePreview href="https://portfolio-magicui.vercel.app/">
Live Preview{" "}
</TemplatePreview>