Spaces:
Build error
Build error
Upload pages/api/database/stats.js with huggingface_hub
Browse files- pages/api/database/stats.js +17 -0
pages/api/database/stats.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { DatabaseManager } from '../../lib/database-manager';
|
| 2 |
+
|
| 3 |
+
export default function handler(req, res) {
|
| 4 |
+
if (req.method !== 'GET') {
|
| 5 |
+
return res.status(405).json({ error: 'Method not allowed' });
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
try {
|
| 9 |
+
const db = new DatabaseManager();
|
| 10 |
+
const stats = db.getStats();
|
| 11 |
+
|
| 12 |
+
res.status(200).json(stats);
|
| 13 |
+
} catch (error) {
|
| 14 |
+
console.error('Database error:', error);
|
| 15 |
+
res.status(500).json({ error: 'Failed to fetch stats' });
|
| 16 |
+
}
|
| 17 |
+
}
|