-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first commit for github-repo-download through api
- Loading branch information
0 parents
commit a7f7c8d
Showing
17 changed files
with
5,349 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GITHUB_ACCESS_TOKEN="" | ||
NEXT_PUBLIC_URL="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
|
||
## Getting Started | ||
|
||
First, run the development server: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
# or | ||
pnpm dev | ||
# or | ||
bun dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. | ||
|
||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. | ||
|
||
## Learn More | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
|
||
## Deploy on Vercel | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
|
||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { Octokit } from "octokit"; | ||
|
||
const octokit = new Octokit({ | ||
auth: process.env.GITHUB_ACCESS_TOKEN, | ||
}); | ||
|
||
export async function POST() { | ||
try { | ||
const response = await octokit.request( | ||
"GET /repos/{owner}/{repo}/zipball", | ||
{ | ||
owner: "repo__owner__example__[itsarghyadas]", | ||
repo: "repo_name__example__[github-repo-download-api]", | ||
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) { | ||
console.error("Error fetching repository zipball:", error); | ||
return NextResponse.json( | ||
{ success: false, error: "Failed to fetch repository zipball." }, | ||
{ status: 500 } | ||
); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
@layer base { | ||
.bg-pattern::before { | ||
content: ""; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
z-index: -1; | ||
background-color: #e5e5f7; | ||
opacity: 0.15; | ||
background-image: linear-gradient( | ||
30deg, | ||
#444cf7 12%, | ||
transparent 12.5%, | ||
transparent 87%, | ||
#444cf7 87.5%, | ||
#444cf7 | ||
), | ||
linear-gradient( | ||
150deg, | ||
#444cf7 12%, | ||
transparent 12.5%, | ||
transparent 87%, | ||
#444cf7 87.5%, | ||
#444cf7 | ||
), | ||
linear-gradient( | ||
30deg, | ||
#444cf7 12%, | ||
transparent 12.5%, | ||
transparent 87%, | ||
#444cf7 87.5%, | ||
#444cf7 | ||
), | ||
linear-gradient( | ||
150deg, | ||
#444cf7 12%, | ||
transparent 12.5%, | ||
transparent 87%, | ||
#444cf7 87.5%, | ||
#444cf7 | ||
), | ||
linear-gradient( | ||
60deg, | ||
#444cf777 25%, | ||
transparent 25.5%, | ||
transparent 75%, | ||
#444cf777 75%, | ||
#444cf777 | ||
), | ||
linear-gradient( | ||
60deg, | ||
#444cf777 25%, | ||
transparent 25.5%, | ||
transparent 75%, | ||
#444cf777 75%, | ||
#444cf777 | ||
); | ||
background-size: 20px 35px; | ||
background-position: 0 0, 0 0, 10px 18px, 10px 18px, 0 0, 10px 18px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { Metadata } from "next"; | ||
import { Gabarito } from "next/font/google"; | ||
import "./globals.css"; | ||
|
||
const gabarito = Gabarito({ subsets: ["latin"] }); | ||
|
||
export const metadata: Metadata = { | ||
title: "Create Next App", | ||
description: "Generated by create next app", | ||
}; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<html lang="en"> | ||
<body className={gabarito.className}>{children}</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"use client"; | ||
import axios from "axios"; | ||
import { useState } from "react"; | ||
const webUrl = process.env.NEXT_PUBLIC_URL; | ||
|
||
export default function Page() { | ||
const [loading, setLoading] = useState(false); | ||
|
||
const handleDownload = () => { | ||
console.log("download"); | ||
setLoading(true); | ||
axios | ||
.post(`${webUrl}/api/repo`) | ||
.then((response) => { | ||
const downloadUrl = response.data.downloadUrl; | ||
const status = response.data.status; | ||
window.location.href = downloadUrl; | ||
}) | ||
.catch((error) => { | ||
console.log("error", error); | ||
}) | ||
.finally(() => { | ||
setLoading(false); | ||
}); | ||
}; | ||
|
||
return ( | ||
<section className="bg-pattern relative isolate min-h-screen flex items-center justify-center"> | ||
<div className="border rounded-xl bg-indigo-600 ring-2 ring-offset-2 ring-indigo-500/50 p-20 flex flex-col gap-y-7 items-center justify-center"> | ||
<p className="font-bold text-3xl tracking-tighter text-white"> | ||
Github Repo Download API | ||
</p> | ||
<button | ||
className="bg-white w-full flex items-center gap-x-3 justify-center h-12 text-neutral-900 text-lg font-bold rounded-md hover:bg-neutral-100" | ||
onClick={handleDownload} | ||
disabled={loading} | ||
> | ||
{loading ? "Downloading..." : "Download Repo"} | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
stroke="currentColor" | ||
strokeWidth="2" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
className="lucide lucide-cloud-download" | ||
> | ||
<path d="M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242" /> | ||
<path d="M12 12v9" /> | ||
<path d="m8 17 4 4 4-4" /> | ||
</svg> | ||
</button> | ||
</div> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {} | ||
|
||
module.exports = nextConfig |
Oops, something went wrong.