Reaperxxxx commited on
Commit
e0ea521
·
verified ·
1 Parent(s): 638d329

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +34 -0
index.js CHANGED
@@ -269,6 +269,40 @@ app.get('/user/:id/theme', async (req, res) => {
269
  }
270
  });
271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  // GET /group/:id/meta → returns group metadata from MongoDB (names.json)
273
  app.get('/group/:id/meta', async (req, res) => {
274
  const groupId = req.params.id;
 
269
  }
270
  });
271
 
272
+ app.get('/user/:id/mark', async (req, res) => {
273
+ const userId = req.params.id;
274
+ const filename = 'data/marks.json';
275
+
276
+ const client = new MongoClient(MONGO_URI);
277
+ try {
278
+ await client.connect();
279
+ const db = client.db(DB_NAME);
280
+ const collection = db.collection(COLLECTION_NAME);
281
+
282
+ // Find the document for marks.json
283
+ const doc = await collection.findOne({ filename });
284
+
285
+ if (!doc || !doc.data || !doc.data[userId]) {
286
+ return res.status(404).json({ status: false, message: 'User mark not found' });
287
+ }
288
+
289
+ const { mark, url, lastUpdated } = doc.data[userId];
290
+
291
+ return res.json({
292
+ status: true,
293
+ userId,
294
+ mark,
295
+ url,
296
+ lastUpdated
297
+ });
298
+
299
+ } catch (err) {
300
+ return res.status(500).json({ status: false, error: err.message });
301
+ } finally {
302
+ await client.close();
303
+ }
304
+ });
305
+
306
  // GET /group/:id/meta → returns group metadata from MongoDB (names.json)
307
  app.get('/group/:id/meta', async (req, res) => {
308
  const groupId = req.params.id;