const express = require('express'),
  router = express.Router();

router.get('/', async (req, res/*, next*/) => {
  return res.status(200).send(
    [ {
      id: 1,
      ownerId: 1,
      name: 'Beer Tuesday',
      group: 'beer-tuesday',
      nextEvent: Date.now() + 86400 * 14 * 1000 /* 2 weeks from now */
    } ]
  );
});


router.get('/:groupId/events', async (req, res/*, next*/) => {
  return res.status(200).send(
    [{
      id: 1,
      name: 'Tuesday',
      date: Date.now() + 86400 * 14 * 1000 /* 2 weeks from now */
    }]
  );
});

router.post('/:groupId', async (req, res) => {
  const { groupId } = req.params;
  if (!groupId) {
    return res.status(400).send({ message: `Invalid group.`});
  }
  
  const group = {
    id: groupId
  };
  
  return res.status(200).send({ id: group.id });
});


module.exports = router;
