const {authJwt} = require("../middlewares");
module.exports = app => {
	const snack = require("../controllers/snack.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 snacks
	router.get("/", [authJwt.verifyToken], snack.getAllSnacks);
	// Create a new snack
	router.post("/", [authJwt.verifyToken], snack.createNewSnack);
	router.put('/:id', [authJwt.verifyToken], snack.updateSnack);
	router.delete('/:id', [authJwt.verifyToken], snack.deleteSnack)
	app.use('/api/snacks', router);
};