Koddenbrock commited on
Commit
6895b85
·
1 Parent(s): 2f90f65

add admin endpoint to retrieve full session list for dashboard

Browse files
Files changed (1) hide show
  1. server.js +6 -0
server.js CHANGED
@@ -126,6 +126,12 @@ app.get('/api/leaderboard', (req, res) => {
126
  res.json(sorted);
127
  });
128
 
 
 
 
 
 
 
129
  // GET /api/export — download full raw data (admin only)
130
  app.get('/api/export', adminAuth, (req, res) => {
131
  res.setHeader('Content-Disposition', 'attachment; filename="2afc_data.json"');
 
126
  res.json(sorted);
127
  });
128
 
129
+ // GET /api/admin/sessions — full session list for the admin dashboard (admin only)
130
+ app.get('/api/admin/sessions', adminAuth, (req, res) => {
131
+ const { sessions } = readData();
132
+ res.json([...sessions].sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp)));
133
+ });
134
+
135
  // GET /api/export — download full raw data (admin only)
136
  app.get('/api/export', adminAuth, (req, res) => {
137
  res.setHeader('Content-Disposition', 'attachment; filename="2afc_data.json"');