Files
ReadMeABook/src/app/api/admin/users/route.ts
T
kikootwo 4b90b35748 Add Transmission/NZBGet and per-client paths and much more
Extend multi-download-client support to include Transmission and NZBGet and introduce per-client custom download paths. Adds protocol mapping and new client types, Transmission/NZBGet integration services, API CRUD and validation changes, UI components/modal updates and live path previews, and manager routing by protocol. Includes DB migrations (download_path on download_history, interactive_search_access on users), schema updates, and related processor/service fixes and tests to ensure backward compatibility and proper path resolution.
2026-02-09 19:45:43 -05:00

57 lines
1.6 KiB
TypeScript

/**
* Component: Admin Users API
* Documentation: documentation/admin-dashboard.md
*/
import { NextRequest, NextResponse } from 'next/server';
import { requireAuth, requireAdmin, AuthenticatedRequest } from '@/lib/middleware/auth';
import { prisma } from '@/lib/db';
import { RMABLogger } from '@/lib/utils/logger';
const logger = RMABLogger.create('API.Admin.Users');
export async function GET(request: NextRequest) {
return requireAuth(request, async (req: AuthenticatedRequest) => {
return requireAdmin(req, async () => {
try {
const users = await prisma.user.findMany({
where: {
deletedAt: null, // Exclude soft-deleted users
},
select: {
id: true,
plexId: true,
plexUsername: true,
plexEmail: true,
role: true,
isSetupAdmin: true,
authProvider: true,
avatarUrl: true,
createdAt: true,
updatedAt: true,
lastLoginAt: true,
autoApproveRequests: true,
interactiveSearchAccess: true,
_count: {
select: {
requests: true,
},
},
},
orderBy: {
createdAt: 'desc',
},
});
return NextResponse.json({ users });
} catch (error) {
logger.error('Failed to fetch users', { error: error instanceof Error ? error.message : String(error) });
return NextResponse.json(
{ error: 'Failed to fetch users' },
{ status: 500 }
);
}
});
});
}