Skip to content

Commit 6579d11

Browse files
committed
fix: resolve TypeScript compilation errors
- Add proper TypeScript interfaces for GitHub webhook payload - Fix middleware unused parameter warning - Add location fields to search index - Correct function import name in enrichment script
1 parent 3827764 commit 6579d11

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

app/api/webhook/route.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ import { NextRequest, NextResponse } from "next/server";
22
import { revalidateTag } from "next/cache";
33
import crypto from "crypto";
44

5+
interface GitHubCommit {
6+
added?: string[];
7+
modified?: string[];
8+
removed?: string[];
9+
}
10+
11+
interface GitHubWebhookPayload {
12+
ref?: string;
13+
repository?: {
14+
default_branch?: string;
15+
};
16+
commits?: GitHubCommit[];
17+
}
18+
519
function verifySignature(payload: string, signature: string, secret: string): boolean {
620
const hmac = crypto.createHmac("sha256", secret);
721
const digest = `sha256=${hmac.update(payload).digest("hex")}`;
@@ -28,12 +42,12 @@ export async function POST(request: NextRequest) {
2842
return NextResponse.json({ error: "Invalid signature" }, { status: 401 });
2943
}
3044

31-
const payload = JSON.parse(body);
45+
const payload = JSON.parse(body) as GitHubWebhookPayload;
3246

3347
// Handle push events
3448
if (payload.ref === `refs/heads/${payload.repository?.default_branch}`) {
3549
// Check if commits touched project files
36-
const touchedProjects = payload.commits?.some((commit: any) => {
50+
const touchedProjects = payload.commits?.some((commit: GitHubCommit) => {
3751
const files = [
3852
...(commit.added || []),
3953
...(commit.modified || []),

middleware.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { NextResponse } from "next/server";
22
import type { NextRequest } from "next/server";
33

4-
export function middleware(request: NextRequest) {
5-
// Basic rate limiting using headers (best-effort without DB)
6-
const ip = request.ip || request.headers.get("x-forwarded-for") || "unknown";
7-
4+
export function middleware(_request: NextRequest) {
85
// Add security headers
96
const response = NextResponse.next();
107

scripts/build-index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ async function buildIndex() {
2323
verified: project.verified || false,
2424
added_at: project.added_at,
2525
looking_for_contributors: project.looking_for_contributors || false,
26+
location_city: project.location_city,
27+
location_indian_state: project.location_indian_state,
2628
}));
2729

2830
// Sort by name for deterministic output

scripts/enrich.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import fs from "fs";
44
import path from "path";
55
import { loadAllProjects } from "../lib/projects";
6-
import { getRepoMetadata, countGoodFirstIssues, hasWbfossTopic, hasVerifiedBadge } from "../lib/github";
6+
import { getRepoMetadata, countGoodFirstIssues, hasFossradarTopic, hasVerifiedBadge } from "../lib/github";
77

88
async function enrichProjects() {
99
console.log("🔄 Enriching project data...\n");
@@ -32,7 +32,7 @@ async function enrichProjects() {
3232
const goodFirstIssues = await countGoodFirstIssues(project.repo);
3333

3434
// Check verification status
35-
const hasTopic = await hasWbfossTopic(project.repo);
35+
const hasTopic = await hasFossradarTopic(project.repo);
3636
const hasBadge = await hasVerifiedBadge(project.repo);
3737
const verified = hasTopic && hasBadge;
3838

0 commit comments

Comments
 (0)