const express = require('express')
const router = express.Router()
const {
getProducts,
getProduct,
createProduct,
updateProduct,
deleteProduct
} = require('../controllers/products.js')
router.get('/', getProducts)
router.get('/:productID', getProduct)
router.post('/', createProduct)
router.put('/:productID', updateProduct)
router.delete('/:productID', deleteProduct)
module.exports = router
const express = require('express');
const router = express.Router();
// Get to home controller req and res function
router.get('/', app.home);
//---- Inside controller.js
const home = (req, res) => {
res.setHeader('Cache-Control', 'no-cache');
res.status(200).json({
status: 'Ok'
});
};
//----
// NOT FOUND Middleware
router.use((req, res) => {
res.status(404).json('not found');
});
module.exports = router;