You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
748 B
JavaScript

const express = require('express');
const router = express.Router();
const productController = require('../controllers/product');
const auth = require('./auth'); // Assuming you have an auth.js file with authentication middleware
// Middleware for authorization token
const authenticateToken = auth.authenticateToken;
// Create a product route (accessible only by isAdmin)
router.post('/create', authenticateToken, productController.createProduct);
// Retrieve all products route (accessible to both admin and normal user)
router.get('/all', productController.getAllProducts);
// Retrieve all active products route (accessible to both admin and normal user)
router.get('/active', productController.getActiveProducts);
module.exports = router;