diff options
author | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-07-30 10:50:09 +0530 |
---|---|---|
committer | Biswakalyan Bhuyan <biswa@surgot.in> | 2024-07-30 10:50:09 +0530 |
commit | 4bb13ee84f6bb51cba6544ccd0690ab2049512a9 (patch) | |
tree | 27fb2c524658228876de5c06c5e0e63e754c54ea | |
parent | ac590fd41364a31a55f11b6dc54199a76e687636 (diff) | |
download | admin-panel-4bb13ee84f6bb51cba6544ccd0690ab2049512a9.tar.gz admin-panel-4bb13ee84f6bb51cba6544ccd0690ab2049512a9.tar.bz2 admin-panel-4bb13ee84f6bb51cba6544ccd0690ab2049512a9.zip |
removed the view count and view show
-rw-r--r-- | backend/index.js | 30 |
1 files changed, 0 insertions, 30 deletions
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); |