Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Export and Api error resolved." #28

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
GITHUB_TOKEN=YOUR_GITHUB_TOKEN
GEMINI_KEY=YOUR_GEMINI_API_KEY
# Steps to create:
# 1. Go to Settings -> Developer settings -> Personal access tokens -> Tokens (classic) -> Generate new token -> Generate new token (classic)
# 2. Permissions: repo, user
# 3. Generate token
# 4. Copy token
# 5. Paste token in .env.local
# 5. Paste token in .env.local
15 changes: 8 additions & 7 deletions src/app/api/ai/route.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { NextResponse } from "next/server";
const GITHUB_API_URL = "https://api.github.com/graphql";

// Declare contributions as an empty object globally
let contributions = {};

export async function POST(req) {
const { username } = await req.json();

Expand Down Expand Up @@ -61,14 +58,18 @@ export async function POST(req) {
const data = await response.json();
console.log(data);
if (data.data.user) {
contributions = data.data.user.contributionsCollection; // Assign contributions globally
return contributions;
const contributions = data.data.user.contributionsCollection;
return NextResponse.json({
exists: true,
totalContributions: contributions.totalCommitContributions,
activeCodingDays: contributions.contributionCalendar.totalContributions
});
} else {
return null;
return NextResponse.json({ exists: false });
}
} catch (error) {
console.error("Error checking GitHub username:", error);
return new NextResponse("Internal Server Error", { status: 500 });
}
}
export { contributions };
export default contributions;
Loading