From 4bb13ee84f6bb51cba6544ccd0690ab2049512a9 Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Tue, 30 Jul 2024 10:50:09 +0530 Subject: removed the view count and view show --- backend/index.js | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'backend') diff --git a/backend/index.js b/backend/index.js index 7f5ce96..9f3047b 100644 --- a/backend/index.js +++ b/backend/index.js @@ -129,36 +129,6 @@ app.get('/ads', async (req, res, next) => { } }); -// Increment ad view count route -app.post('/ads/:id/view', async (req, res, next) => { - const { id } = req.params; - - try { - const adRef = db.collection('ads').doc(id); - await adRef.update({ - view_count: admin.firestore.FieldValue.increment(1), - }); - res.status(200).json({ message: 'View count incremented' }); - } catch (error) { - next(error); // Pass the error to the error handling middleware - } -}); - -// Get ad view counts route -app.get('/ads/:id/view-count', async (req, res, next) => { - const { id } = req.params; - - try { - const adDoc = await db.collection('ads').doc(id).get(); - if (!adDoc.exists) { - return res.status(404).json({ error: 'Ad not found' }); - } - res.json({ view_count: adDoc.data().view_count }); - } catch (error) { - next(error); // Pass the error to the error handling middleware - } -}); - // Centralized error handling middleware app.use((err, req, res, next) => { console.error('Server Error:', err); -- cgit v1.2.3-59-g8ed1b