text: const express = require('express');
  const router = express.Router();
  const { validateCampground, isLoggedIn, isAuthor } = require('../middleware');
  const catchAsync = require('../utils/catchAsync');
  const campgrounds = require('../controllers/campgrounds');
  const multer = require('multer');
  const { storage } = require('../cloudinary');
  const upload = multer({ storage });
  
  router
    .route('/')
    .get(catchAsync(campgrounds.index))
    .post(
      isLoggedIn,
      upload.array('campground[image]'),
      validateCampground,
      catchAsync(campgrounds.createCampground)
    );
  
  router.get('/new', isLoggedIn, campgrounds.renderNewForm);
  
  router
    .route('/:id')
    .get(catchAsync(campgrounds.showCampground))
    .put(
      isLoggedIn,
      isAuthor,
      upload.array('campground[image]'),
      validateCampground,
      catchAsync(campgrounds.updateCampground)
    )
    .delete(isLoggedIn, isAuthor, catchAsync(campgrounds.deleteCampground));
  
  router.get(
    '/:id/edit',
    isLoggedIn,
    isAuthor,
    catchAsync(campgrounds.renderEditForm)
  );
  
  module.exports = router;
  