const express = require('express');
const moment = require('moment');
const menu = require('../menu-parser');
const GLOBALS = require('./globals');

const router = express.Router();

router.get('/', (req, res) => {
  menu.getMenuForCurrentWeek().then(meals => {
    res.send(meals);
  });
});

router.get('/:day', (req, res) => {
  menu.getMenuForCurrentWeek().then(meals => {
    let day = req.params.day === 'today' ? moment().format('dddd').toLowerCase() : req.params.day;
    if (GLOBALS.workingDays.indexOf(day) >= 0) {
      res.json(meals[day]);
    } else {
      res.status(400).send({
        message: `Today is ${day}, you shouldn't have to work 😝`
      })
    }
  });
});

router.get('/:day/:type', (req, res) => {
  menu.getMenuForCurrentWeek().then(meals => {
    res.json(meals[req.params.day][req.params.type]);
  });
});

module.exports = router;

@@ -173,17 +173,16 @@
 Router()
-;
 %0A%0Arouter
@@ -229,32 +229,35 @@
 ForCurrentWeek()
+%0A  
 .then(meals =%3E %7B
@@ -278,16 +278,71 @@
 meals);%0A
+  %7D)%0A  .catch(err =%3E %7B%0A    sendErrorMessage(res, err);%0A
   %7D);%0A%7D)
@@ -402,32 +402,35 @@
 ForCurrentWeek()
+%0A  
 .then(meals =%3E %7B
@@ -736,167 +736,291 @@
   %7D)
-;%0A%7D);%0A%0Arouter.get('/:day/:type', (req, res) =%3E %7B%0A  menu.getMenuForCurrentWeek().then(meals =%3E %7B%0A    res.json(meals%5Breq.params.day%5D%5Breq.params.type%5D);%0A  %7D);%0A%7D);
+%0A  .catch(err =%3E %7B%0A    sendErrorMessage(res, err);%0A  %7D);%0A%7D);%0A%0Afunction sendErrorMessage(res, err) %7B%0A  if(err.parserError) %7B%0A    res.status(400).send(%7B%0A      message: 'Maybe is too soon to get this week menu %F0%9F%98%B3 Please, try later'%0A    %7D);%0A  %7D else %7B%0A    res.status(400).send(err);%0A  %7D%0A%7D
 %0A%0Amo

Add modifications to API