diff options
-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); |