From 191b352520288efccef405fefd07392dd8544fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20=C4=B0pek?= Date: Tue, 24 Feb 2026 18:13:14 +0300 Subject: [PATCH] remove unused admin users and stats API routes --- app/api/admin/stats/route.ts | 58 ------------------------------------ app/api/admin/users/route.ts | 34 --------------------- 2 files changed, 92 deletions(-) delete mode 100644 app/api/admin/stats/route.ts delete mode 100644 app/api/admin/users/route.ts diff --git a/app/api/admin/stats/route.ts b/app/api/admin/stats/route.ts deleted file mode 100644 index 580511b..0000000 --- a/app/api/admin/stats/route.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { NextResponse } from 'next/server'; -import { db } from '@/lib/db'; -import { auth } from '@/lib/auth'; -import { getCachedTotalStorage } from '@/lib/admin-stats'; - -export async function GET() { - try { - const session = await auth(); - if (!session?.user?.isAdmin) { - return new NextResponse('Unauthorized', { status: 403 }); - } - - // 1. Database Stats - const [ - totalUsers, - totalProjects, - totalVideos, - totalComments, - totalVoiceComments, - totalImageComments, - ] = await Promise.all([ - db.user.count(), - db.project.count(), - db.video.count(), - db.comment.count(), - db.comment.count({ - where: { - voiceUrl: { - not: null, - } - } - }), - db.comment.count({ - where: { - imageUrl: { - not: null, - } - } - }) - ]); - - // 2. Storage Stats (Cached) - const totalStorageBytes = await getCachedTotalStorage(); - - return NextResponse.json({ - totalUsers, - totalProjects, - totalVideos, - totalComments, - totalVoiceComments, - totalImageComments, - totalStorageBytes, - }); - } catch (error) { - console.error('[ADMIN_STATS_GET]', error); - return new NextResponse('Internal Error', { status: 500 }); - } -} diff --git a/app/api/admin/users/route.ts b/app/api/admin/users/route.ts deleted file mode 100644 index fa69863..0000000 --- a/app/api/admin/users/route.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { NextResponse } from 'next/server'; -import { db } from '@/lib/db'; -import { auth } from '@/lib/auth'; - -export async function GET() { - try { - const session = await auth(); - if (!session?.user?.isAdmin) { - return new NextResponse('Unauthorized', { status: 403 }); - } - - const users = await db.user.findMany({ - orderBy: { createdAt: 'desc' }, - select: { - id: true, - name: true, - email: true, - createdAt: true, - _count: { - select: { - ownedWorkspaces: true, - projects: true, - comments: true, - } - } - } - }); - - return NextResponse.json({ users }); - } catch (error) { - console.error('[ADMIN_USERS_GET]', error); - return new NextResponse('Internal Error', { status: 500 }); - } -}