Skip to content
Open
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
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"jose": "^5.9.6",
"next": "15.0.7",
"octokit": "^4.0.2",
"react": "19.0.0-rc-66855b96-20241106",
"react-dom": "19.0.0-rc-66855b96-20241106"
"react": "^19.0.1",
"react-dom": "^19.0.1"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript type definitions not updated for React 19

Medium Severity

The React runtime dependencies were upgraded to version 19.x (^19.0.1), but @types/react and @types/react-dom remain at version ^18. These type packages provide TypeScript definitions, and React 19 has significant API changes from React 18. The @types/react@19.x packages exist and provide correct typings for React 19. Using mismatched type definitions can cause incorrect type checking, missing types for new React 19 APIs, and potential runtime surprises when the types don't match actual behavior.

Fix in Cursor Fix in Web

},
"devDependencies": {
"@types/node": "^20",
Expand Down
52 changes: 34 additions & 18 deletions src/app/githubApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,35 @@ import { Octokit } from "octokit";
import { Repo } from "@/types/repo";
import { createAppAuth } from "@octokit/auth-app";

const octokit = new Octokit({
authStrategy: createAppAuth,
auth: {
appId: process.env.GITHUB_APP_ID,
privateKey: process.env.GITHUB_PRIVATE_KEY,
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
installationId: process.env.GITHUB_INSTALLATION_ID,
},
});
function getRequiredEnv(name: string) {
const value = process.env[name];
if (!value) {
throw new Error(`Missing required environment variable: ${name}`);
}
return value;
}

let octokit: Octokit | null = null;
function getOctokit() {
if (octokit) return octokit;

// Ensure we don't throw during module evaluation (e.g. at build time).
octokit = new Octokit({
authStrategy: createAppAuth,
auth: {
appId: Number(getRequiredEnv("GITHUB_APP_ID")),
privateKey: getRequiredEnv("GITHUB_PRIVATE_KEY").replace(/\\n/g, "\n"),
clientId: getRequiredEnv("GITHUB_CLIENT_ID"),
clientSecret: getRequiredEnv("GITHUB_CLIENT_SECRET"),
installationId: Number(getRequiredEnv("GITHUB_INSTALLATION_ID")),
},
});

return octokit;
}

export async function getUser(username: string) {
const request = octokit.request("GET /users/{username}", {
const request = getOctokit().request("GET /users/{username}", {
username: username,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
Expand All @@ -28,7 +44,7 @@ export async function getUser(username: string) {
}

export async function getRepos(username: string) {
const request = octokit.request("GET /users/{username}/repos", {
const request = getOctokit().request("GET /users/{username}/repos", {
username: username,
headers: {
"X-GitHub-Api-Version": "2022-11-28",
Expand Down Expand Up @@ -62,7 +78,7 @@ export async function getCommits(username: string) {
const currentYear = new Date().getFullYear();
const startDate = `${currentYear}-01-01`;
const endDate = `${currentYear}-12-31`;
const request = octokit.request(
const request = getOctokit().request(
"GET /search/commits?q=author:{username}+committer-date:{startDate}..{endDate}",
{
username: username,
Expand All @@ -87,7 +103,7 @@ export async function getCommitsLastYear(username: string) {
const currentYear = new Date().getFullYear();
const startDate = `${currentYear - 1}-01-01`;
const endDate = `${currentYear - 1}-12-31`;
const request = octokit.request(
const request = getOctokit().request(
"GET /search/commits?q=author:{username}+committer-date:{startDate}..{endDate}",
{
username: username,
Expand All @@ -112,7 +128,7 @@ export async function getPullRequestsMerged(username: string) {
const currentYear = new Date().getFullYear();
const startDate = `${currentYear}-01-01`;
const endDate = `${currentYear}-12-31`;
const request = octokit.request(
const request = getOctokit().request(
"GET /search/issues?q=type:{pr}+author:{username}+is:{merged}+merged:{startDate}..{endDate}",
{
username: username,
Expand All @@ -138,7 +154,7 @@ export async function getPullRequestsMergedLastYear(username: string) {
const currentYear = new Date().getFullYear();
const startDate = `${currentYear - 1}-01-01`;
const endDate = `${currentYear - 1}-12-31`;
const request = octokit.request(
const request = getOctokit().request(
"GET /search/issues?q=type:{pr}+author:{username}+is:{merged}+merged:{startDate}..{endDate}",
{
username: username,
Expand All @@ -165,7 +181,7 @@ export async function getIssuesOpened(username: string) {
const currentYear = new Date().getFullYear();
const startDate = `${currentYear}-01-01`;
const endDate = `${currentYear}-12-31`;
const request = octokit.request(
const request = getOctokit().request(
"GET /search/issues?q=author:{username}+is:{issue}+created:{startDate}..{endDate}",
{
username: username,
Expand All @@ -191,7 +207,7 @@ export async function getIssuesOpenedLastYear(username: string) {
const currentYear = new Date().getFullYear();
const startDate = `${currentYear - 1}-01-01`;
const endDate = `${currentYear - 1}-12-31`;
const request = octokit.request(
const request = getOctokit().request(
"GET /search/issues?q=author:{username}+is:{issue}+created:{startDate}..{endDate}",
{
username: username,
Expand Down