Refactor: Improve error handling in authentication flow

This commit is contained in:
Your Name
2026-04-17 19:55:35 +00:00
parent 7c5da339cb
commit 61bbca2e5d
33 changed files with 2834 additions and 4185 deletions
+30
View File
@@ -132,4 +132,34 @@ router.get('/me/requests',
})
);
// Get leaderboard
router.get('/leaderboard',
authenticate,
asyncHandler(async (_req: AuthenticatedRequest, res) => {
const topEarners = await prisma.user.findMany({
orderBy: { totalEarned: 'desc' },
take: 10,
select: {
id: true,
plexUsername: true,
totalEarned: true,
watchTimeMinutes: true
}
});
const topWatchers = await prisma.user.findMany({
orderBy: { watchTimeMinutes: 'desc' },
take: 10,
select: {
id: true,
plexUsername: true,
totalEarned: true,
watchTimeMinutes: true
}
});
res.json({ topEarners, topWatchers });
})
);
export { router as userRouter };