Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/app/api/ai-insights/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
import { resolveAppUser } from "@/lib/resolve-user";
Expand Down Expand Up @@ -63,7 +63,7 @@ interface ReposApiResponse {
}

export async function GET(request: Request) {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

if (!session?.githubId) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/ai/weekly-summary/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/

import { NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
import { resolveAppUser } from "@/lib/resolve-user";
Expand Down Expand Up @@ -151,7 +151,7 @@ function validateBody(body: unknown): ValidationResult | ValidationError {

export async function POST(req: Request): Promise<NextResponse> {
// 1. Authentication
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/auth/link-github/callback/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-nocheck
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { cookies } from "next/headers";
import { NextRequest, NextResponse } from "next/server";
import { authOptions } from "@/lib/auth";
Expand Down Expand Up @@ -36,7 +36,7 @@ export async function GET(req: NextRequest) {
);
}

const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

if (!session?.githubId) {
return NextResponse.redirect(
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/auth/link-github/route.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { randomBytes } from "crypto";
import { NextResponse } from "next/server";
import { authOptions } from "@/lib/auth";

export async function GET() {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

if (!session?.githubId) {
return NextResponse.json(
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/cv/analyze/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
import type { ContributionClassification, CVAnalyzeResponse } from "@/types/cv-types";
Expand All @@ -24,7 +24,7 @@ const MAX_REQUESTS = 3;
export async function POST() {
try {
/* ── 1. Auth ─────────────────────────────────────────────── */
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

if (!session?.githubId) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/cv/export/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import type { CVExportRequest, ResumeContent } from "@/types/cv-types";

Expand Down Expand Up @@ -183,7 +183,7 @@ async function toPdf(content: ResumeContent): Promise<ArrayBuffer> {
export async function POST(request: Request) {
try {
/* ── 1. Auth ─────────────────────────────────────────────── */
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

if (!session?.githubId) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/cv/generate/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
import type {
Expand Down Expand Up @@ -29,7 +29,7 @@ const MAX_REQUESTS = 5;
export async function POST(request: Request) {
try {
/* ── 1. Auth ─────────────────────────────────────────────── */
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

if (!session?.githubId) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
Expand Down
8 changes: 4 additions & 4 deletions src/app/api/daily-focus/route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { NextResponse, NextRequest } from "next/server";
import { supabaseAdmin } from "@/lib/supabase";
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { resolveAppUser } from "@/lib/resolve-user";

export async function GET(req: NextRequest) {
try {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down Expand Up @@ -38,7 +38,7 @@ export async function GET(req: NextRequest) {

export async function POST(req: NextRequest) {
try {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down Expand Up @@ -76,7 +76,7 @@ export async function POST(req: NextRequest) {

export async function DELETE(req: NextRequest) {
try {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/daily-note/route.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { NextResponse, NextRequest } from "next/server";
import { supabaseAdmin } from "@/lib/supabase";
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { resolveAppUser } from "@/lib/resolve-user";

export const dynamic = "force-dynamic";

async function getAppUserId(req: NextRequest): Promise<string | null> {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) return null;
const user = await resolveAppUser(session.githubId, session.githubLogin);
return user?.id ?? null;
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/debug/health/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type NextRequest, NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";

Expand Down Expand Up @@ -90,7 +90,7 @@ export async function GET(req: NextRequest) {
// Session check — return only a boolean; never expose account identifiers
// (githubId, githubLogin) because this endpoint is reachable by anyone
// who holds the DEBUG_SECRET, which may differ from the account owner.
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

return NextResponse.json({
status: "ok",
Expand Down
6 changes: 3 additions & 3 deletions src/app/api/goals/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
import { resolveAppUser } from "@/lib/resolve-user";
Expand All @@ -23,7 +23,7 @@ export async function PATCH(
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params;
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down Expand Up @@ -183,7 +183,7 @@ export async function DELETE(
) {
const { id } = await params;
try {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/goals/history/route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
import { resolveAppUser } from "@/lib/resolve-user";

export const dynamic = "force-dynamic";

export async function GET(req: Request) {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/api/goals/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
import { resolveAppUser } from "@/lib/resolve-user";
Expand Down Expand Up @@ -63,7 +63,7 @@ function getPreviousPeriodEnd(periodStart: Date): string {
}

export async function GET() {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down Expand Up @@ -183,7 +183,7 @@ export async function GET() {
}

export async function POST(req: Request) {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/goals/sync/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
import { extractValidRepoFromGoal, type ActivityGoal } from "@/lib/goals-sync-utils";
Expand Down Expand Up @@ -35,7 +35,7 @@ const GITHUB_API = "https://api.github.com";


export async function POST() {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.accessToken || !session.githubId || !session.githubLogin) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/integrations/jira/credentials/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { NextRequest } from "next/server";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
Expand Down Expand Up @@ -40,7 +40,7 @@ async function testJiraConnection(
}

async function requireUser(): Promise<{ user: AppUser } | { error: Response }> {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

if (!session?.githubId || !session?.githubLogin) {
return { error: Response.json({ error: "Unauthorized" }, { status: 401 }) };
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/integrations/jira/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextRequest } from "next/server";
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
import { resolveAppUser, AppUser } from "@/lib/resolve-user";
Expand All @@ -17,7 +17,7 @@ interface JiraCredentials {
}

async function requireUser(): Promise<{ user: AppUser } | { error: Response }> {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

if (!session?.githubId || !session?.githubLogin) {
return { error: Response.json({ error: "Unauthorized" }, { status: 401 }) };
Expand Down
8 changes: 4 additions & 4 deletions src/app/api/local-coding/keys/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { NextRequest } from "next/server";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
Expand All @@ -14,7 +14,7 @@ function hashApiKey(key: string): string {
}

export async function GET() {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
Expand All @@ -40,7 +40,7 @@ export async function GET() {
}

export async function POST(req: NextRequest) {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down Expand Up @@ -113,7 +113,7 @@ export async function POST(req: NextRequest) {
}

export async function DELETE(req: NextRequest) {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/local-coding/stats/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { NextRequest } from "next/server";
import { authOptions } from "@/lib/auth";
import { supabaseAdmin } from "@/lib/supabase";
Expand All @@ -17,7 +17,7 @@ function validateDays(days: number): number {
}

export async function GET(req: NextRequest) {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.githubId) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/metrics/achievement-progress/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { NextRequest } from "next/server";
import { authOptions } from "@/lib/auth";
import { GitHubAuthError, githubAuthErrorResponse } from "@/lib/github-fetch";
Expand Down Expand Up @@ -95,7 +95,7 @@ async function fetchAchievementMetrics(
// --- Route handler -----------------------------------------------------------

export async function GET(req: NextRequest) {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

if (!session?.accessToken || !session.githubId || !session.githubLogin) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/metrics/achievements/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { NextRequest } from "next/server";
import { authOptions } from "@/lib/auth";
import { isMetricsCacheBypassed } from "@/lib/metrics-cache";
Expand All @@ -8,7 +8,7 @@ import { syncGitHubAchievementsForUser } from "@/lib/github-achievements";
export const dynamic = "force-dynamic";

export async function GET(req: NextRequest) {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

if (!session?.accessToken || !session.githubId || !session.githubLogin) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/metrics/activity/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { NextRequest } from "next/server";
import { authOptions } from "@/lib/auth";
import { getAccountToken, getAllAccounts } from "@/lib/github-accounts";
Expand Down Expand Up @@ -152,7 +152,7 @@ async function fetchFormattedActivityWithFallback(
}

export async function GET(req: NextRequest) {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();

if (!session?.accessToken || !session.githubLogin) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/metrics/ci/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getServerSession } from "next-auth";
import { getServerAuthSession } from "@/lib/server-auth";
import { NextRequest } from "next/server";
import { authOptions } from "@/lib/auth";
import { getAccountToken, getAllAccounts, mergeMetrics } from "@/lib/github-accounts";
Expand All @@ -10,7 +10,7 @@ import { fetchCIAnalyticsForAccount, mergeCIAnalytics } from "@/lib/ci-analytics
export const dynamic = "force-dynamic";

export async function GET(req: NextRequest) {
const session = await getServerSession(authOptions);
const session = await getServerAuthSession();
if (!session?.accessToken || !session.githubLogin) return Response.json({ error: "Unauthorized" }, { status: 401 });

const accountId = req.nextUrl.searchParams.get("accountId");
Expand Down
Loading
Loading