text: const express = require('express'),
      router = express.Router();
  
  const {createCar, getCarById, updateCarById, deleteCarById} = require('../../../controllers/cars')
  
  router
      .get('/:id', async function (req, res) {
          const {id} = req.params
          const car = await getCarById(id)
          res.send(car)
      })
      .post('/:id', async function (req, res) {
          const {id} = req.params
          const car = await updateCarById(id, req.body)
          res.send(car)
      })
      .put('/:id', async function (req, res) {
          const {id} = req.params
          let car = await getCarById(id)
  
          if (!car) {
              car = await createCar(req.body)
          }
          else {
              car = await updateCarById(id, req.body)
          }
  
          res.send(car)
      })
      .delete('/:id', async function (req, res) {
          const {id} = req.params
          const car = await deleteCarById(id)
          res.send(car)
      })
  
  
  module.exports = router;
  