const {authJwt} = require("../middlewares");
module.exports = app => {
	const lunch = require("../controllers/lunch.controller.js");
	app.use((req, res, next) => {
		res.header(
			"Access-Control-Allow-Headers",
			"x-access-token, Origin, Content-Type, Accept"
		);
		next();
	});
	var router = require("express").Router();
	// Retrieve all lunches
	router.get("/", [authJwt.verifyToken], lunch.getAllLunches);
	// Create a new Lunch
	router.post("/", [authJwt.verifyToken], lunch.createNewLunch);
	router.put('/:id', [authJwt.verifyToken], lunch.updateLunch);
	router.delete('/:id', [authJwt.verifyToken], lunch.deleteLunch)
	app.use('/api/lunches', router);
};