-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreciepeController.js
More file actions
33 lines (27 loc) · 1.18 KB
/
Copy pathreciepeController.js
File metadata and controls
33 lines (27 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const category = [Japanese, Italian, African];
import {addNew, deleterecipe, getAll, getByCategory, updateRecipe} from "../services/reciepeService"
export const getAllRecipe = (req, res) =>{
const recipe = getAll()
res.status(200).json({msg: "success", recipe})
}
export const getByCategory = (req, res) => {
const category = req.query;
const reciepe = getByCategory(category);
res.status(200).json({msg: "success", reciepe})
}
export const updateRecipe = (req, res) => {
const {recipeName, ingredients, duration, procedure, category} = req.body;
const id = req.params.id;
const reciepe = updateRecipe(id, recipeName, ingredients, duration, procedure, category);
res.status(200).json({msg: "updated sucessfully", reciepe})
}
export const addNew = (req, res) => {
const {recipeName, ingredients, duration, procedure, category} = req.body;
const reciepe = addNew(recipeName, ingredients, duration, procedure, category);
res.status(200).json({msg: "sucessfully added"});
}
export const deleterecipe = (req, res) => {
const id = req.params.id;
const reciepe = deleterecipe(id);
res.status(200).json({msg: "updated sucessfully", reciepe});
}