-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (23 loc) · 846 Bytes
/
Copy pathindex.js
File metadata and controls
32 lines (23 loc) · 846 Bytes
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
const express = require("express");
const app = express();
const cors = require("cors");
const recipeController = require("./controllers/recipeController");
// const Recipes = require('./models/Recipes');
const bodyParser = require("body-parser");
app.use(bodyParser.json());
app.use(cors());
app.get("/", recipeController.index);
//find recipe by style of food
app.get("/searchByStyle/:name", recipeController.name);
//find by the name
app.get('/searchByTitle/:name', recipeController.searchByTitle)
//create a new recipe
app.post("/new", recipeController.create);
//update a recipe
app.put("/recipe/:name", recipeController.edit);
//delete a recipe
app.delete("/remove/:name", recipeController.delete);
app.set("port", process.env.PORT || 8080);
app.listen(app.get("port"), () => {
console.log(`Check Port: ${app.get('port')}`)
})