From 49c3ac61eaf28a90254631b2fd9f978dc6cac774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20=C4=B0pek?= Date: Sat, 7 Feb 2026 17:28:46 +0300 Subject: [PATCH] refactor: Add explicit types for workspace and project member checks --- app/(dashboard)/workspaces/page.tsx | 2 +- app/api/projects/[projectId]/route.ts | 2 +- .../projects/[projectId]/videos/[videoId]/versions/route.ts | 2 +- app/api/workspaces/[workspaceId]/route.ts | 2 +- lib/r2-cleanup.ts | 6 +++--- package.json | 1 + tsconfig.json | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/(dashboard)/workspaces/page.tsx b/app/(dashboard)/workspaces/page.tsx index e0a654e..0892cbd 100644 --- a/app/(dashboard)/workspaces/page.tsx +++ b/app/(dashboard)/workspaces/page.tsx @@ -66,7 +66,7 @@ export default async function WorkspacesPage() { {/* Workspaces Grid */} {workspaces.length > 0 ? (
- {workspaces.map((workspace) => ( + {workspaces.map((workspace: typeof workspaces[number]) => ( diff --git a/app/api/projects/[projectId]/route.ts b/app/api/projects/[projectId]/route.ts index 371dc8b..6978572 100644 --- a/app/api/projects/[projectId]/route.ts +++ b/app/api/projects/[projectId]/route.ts @@ -83,7 +83,7 @@ export async function GET(request: NextRequest, { params }: RouteParams) { // Check access const isPublic = project.visibility === ProjectVisibility.PUBLIC; const isOwner = session?.user?.id === project.ownerId; - const isMember = project.members.some(m => m.userId === session?.user?.id); + const isMember = project.members.some((m: { userId: string }) => m.userId === session?.user?.id); // Check workspace membership let isWorkspaceMember = false; diff --git a/app/api/projects/[projectId]/videos/[videoId]/versions/route.ts b/app/api/projects/[projectId]/videos/[videoId]/versions/route.ts index b8252c3..e08ff22 100644 --- a/app/api/projects/[projectId]/videos/[videoId]/versions/route.ts +++ b/app/api/projects/[projectId]/videos/[videoId]/versions/route.ts @@ -106,7 +106,7 @@ export async function POST(request: NextRequest, { params }: RouteParams) { const nextVersionNumber = (video.versions[0]?.versionNumber || 0) + 1; // Use transaction to handle active flag - const version = await db.$transaction(async (tx) => { + const version = await db.$transaction(async (tx: Parameters[0]>[0]) => { // If setActive, deactivate all other versions if (setActive) { await tx.videoVersion.updateMany({ diff --git a/app/api/workspaces/[workspaceId]/route.ts b/app/api/workspaces/[workspaceId]/route.ts index 2014042..97630f4 100644 --- a/app/api/workspaces/[workspaceId]/route.ts +++ b/app/api/workspaces/[workspaceId]/route.ts @@ -65,7 +65,7 @@ export async function GET(request: NextRequest, { params }: RouteParams) { // Check access const isOwner = session?.user?.id === workspace.ownerId; - const isMember = workspace.members.some(m => m.userId === session?.user?.id); + const isMember = workspace.members.some((m: { userId: string }) => m.userId === session?.user?.id); if (!isOwner && !isMember) { return apiErrors.forbidden('Access denied'); diff --git a/lib/r2-cleanup.ts b/lib/r2-cleanup.ts index c773e33..72d8f0a 100644 --- a/lib/r2-cleanup.ts +++ b/lib/r2-cleanup.ts @@ -45,7 +45,7 @@ export async function collectVideoVoiceUrls(videoId: string): Promise }, select: { voiceUrl: true }, }); - return comments.map((c) => c.voiceUrl).filter(Boolean) as string[]; + return comments.map((c: { voiceUrl: string | null }) => c.voiceUrl).filter(Boolean) as string[]; } /** @@ -59,7 +59,7 @@ export async function collectProjectVoiceUrls(projectId: string): Promise c.voiceUrl).filter(Boolean) as string[]; + return comments.map((c: { voiceUrl: string | null }) => c.voiceUrl).filter(Boolean) as string[]; } /** @@ -73,7 +73,7 @@ export async function collectWorkspaceVoiceUrls(workspaceId: string): Promise c.voiceUrl).filter(Boolean) as string[]; + return comments.map((c: { voiceUrl: string | null }) => c.voiceUrl).filter(Boolean) as string[]; } /** diff --git a/package.json b/package.json index 24f6680..73bb9c2 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "start": "next start", "lint": "eslint", "typecheck": "tsc --noEmit", + "postinstall": "prisma generate", "db:generate": "prisma generate", "db:push": "prisma db push", "db:migrate": "prisma migrate deploy", diff --git a/tsconfig.json b/tsconfig.json index 3a13f90..7e7f86c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,5 +30,5 @@ ".next/dev/types/**/*.ts", "**/*.mts" ], - "exclude": ["node_modules"] + "exclude": ["node_modules", "prisma/seed.ts"] }