{"size": 816, "ext": "js", "max_stars_repo_path": "controller/menu.js", "max_stars_repo_name": "dhn2018/yingjun-pms", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "controller/menu.js", "max_issues_repo_name": "dhn2018/yingjun-pms", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "controller/menu.js", "max_forks_repo_name": "dhn2018/yingjun-pms", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.2, "max_line_length": 75, "alphanum_fraction": 0.7009803922}
const MenuService = require('../service/menu');
const controllerDecorator = require('./controller-decorator');

exports.getAll = controllerDecorator(async function (req, res) {
    const menus = await MenuService.getAll();
    res.send(menus);
});

exports.update = controllerDecorator(async function (req, res, next) {
    const menu = req.body;
    const updatedMenu = await MenuService.update(menu);
    res.send(updatedMenu);
});


exports.add = controllerDecorator(async function (req, res, next) {
    const menu = req.body;
    console.log(req.body);
    const savedMenu = await MenuService.add(menu);
    res.send(savedMenu);
});


exports.deleteByKey = controllerDecorator(async function (req, res, next) {
    const key = req.params.key;
    await MenuService.deleteByKey(key);
    res.sendSuccess();
});

