{"size": 967, "ext": "js", "max_stars_repo_path": "src/routes/admin/recipes.js", "max_stars_repo_name": "MarioDoncel/LaunchBase", "max_stars_repo_stars_event_min_datetime": "2021-03-22T23:06:11.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-22T23:06:11.000Z", "max_issues_repo_path": "src/routes/admin/recipes.js", "max_issues_repo_name": "MarioDoncel/LaunchBase", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/routes/admin/recipes.js", "max_forks_repo_name": "MarioDoncel/LaunchBase", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 56.8823529412, "max_line_length": 110, "alphanum_fraction": 0.728024819}
const express = require('express')
const routes = express.Router()
const multer = require('../../app/middleware/multer')
const recipes = require('../../app/controller/recipes')
const recipeValidator = require('../../app/validators/recipe')
const {onlyUsers, ownRecipeOrAdmin} = require('../../app/middleware/session')

routes.get("/", onlyUsers, recipes.index); // Mostrar a lista de receitas
routes.get("/create", onlyUsers, recipes.create); // Mostrar formulário de nova receita
routes.get("/:id", onlyUsers, recipes.show); // Exibir detalhes de uma receita
routes.get("/:id/edit", onlyUsers, ownRecipeOrAdmin, recipes.edit); // Mostrar formulário de edição de receita

routes.post("/",  multer.array('images', 5), recipeValidator.post, recipes.post); // Cadastrar nova receita
routes.put("/",  multer.array('images', 5), recipeValidator.update, recipes.put); // Editar uma receita
routes.delete("/", recipes.delete); // Deletar uma receita

module.exports = routes