Files
OFApp/server/dashboard.js
T
Trey T 236f36aae6 Add app auth, dashboard, scheduler, video management, and new scrapers
- JWT-based app authentication with user roles, folder/route access control
- Dashboard with storage stats, health checks, and recent activity
- Auto-download/scrape scheduler (12h interval) with per-user and per-job configs
- Video upload, tagging, HLS transcoding, and detail pages
- New scrapers: LeakGallery, Mega (megajs), yt-dlp
- FlareSolverr integration for Cloudflare-protected sites
- Gallery: advanced filtering (date, size, search), sort modes, equal-mix shuffle
- Forum sites management with stored cookies/auth
- GridWall/GridCell components for responsive media grid
- Media API with folder-access permissions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 07:48:10 -05:00

52 lines
1.5 KiB
JavaScript

import { Router } from 'express';
import {
getStorageStats, getTotalStorageSize, getDownloadsToday,
getRecentDownloads, getMediaFileCount, getAutoDownloadUsers, getAutoScrapeJobs,
getAuthConfig,
} from './db.js';
import { getActiveDownloadCount, getActiveDownloadsList } from './download.js';
import { getActiveScrapeCount, getActiveScrapesList } from './scrape.js';
const router = Router();
router.get('/api/dashboard', (req, res) => {
try {
const storageStats = getStorageStats();
const totalStorage = getTotalStorageSize();
const totalFiles = getMediaFileCount();
const downloadsToday = getDownloadsToday();
const recentDownloads = getRecentDownloads(10);
const autoDownloads = getAutoDownloadUsers();
const autoScrapes = getAutoScrapeJobs();
res.json({
stats: {
totalFiles,
totalStorage,
totalFolders: storageStats.length,
downloadsToday,
},
topFolders: storageStats.slice(0, 10),
activeJobs: {
downloads: getActiveDownloadCount(),
scrapes: getActiveScrapeCount(),
downloadList: getActiveDownloadsList(),
scrapeList: getActiveScrapesList(),
},
auth: {
configured: !!getAuthConfig(),
},
scheduler: {
autoDownloadCount: autoDownloads.length,
autoScrapeCount: autoScrapes.length,
},
recentDownloads,
});
} catch (err) {
console.error('[dashboard] Error:', err.message);
res.status(500).json({ error: err.message });
}
});
export default router;