set up demo mode
This commit is contained in:
parent
9aac6e0eff
commit
04bfdd0c8f
10 changed files with 93 additions and 16 deletions
|
@ -10,7 +10,7 @@ app.use(express.json());
|
|||
// ####### ROUTES #######
|
||||
app.get("/backend/test", async (req, res) => {
|
||||
console.log("test");
|
||||
res.json({ test: "test" });
|
||||
res.json({ env: process.env.NODE_ENV });
|
||||
});
|
||||
// ### GET ALL RECIPES ###
|
||||
app.get("/backend/recipes", async (req, res) => {
|
||||
|
@ -81,6 +81,7 @@ app.get("/backend/recipe/:id", async (req, res) => {
|
|||
|
||||
// ### ADD RECIPE ###
|
||||
app.post("/backend/add-recipe", async (req, res) => {
|
||||
if (process.env.NODE_ENV === 'demo') { return; };
|
||||
const { name, author, cuisine, stars, ingredients, steps, prep_minutes, cook_minutes } = req.body;
|
||||
try {
|
||||
const [id] = await db("recipes").insert(
|
||||
|
@ -118,6 +119,7 @@ app.post("/backend/add-recipe", async (req, res) => {
|
|||
|
||||
// ### SET STARS ###
|
||||
app.post("/backend/set-stars", async (req, res) => {
|
||||
if (process.env.NODE_ENV === 'demo') { return; };
|
||||
const { id, stars } = req.body;
|
||||
try {
|
||||
await db("recipes").where({ id: id }).update({ stars: stars });
|
||||
|
@ -130,6 +132,7 @@ app.post("/backend/set-stars", async (req, res) => {
|
|||
|
||||
// ### DELETE RECIPE ###
|
||||
app.delete("/backend/delete-recipe", async (req, res) => {
|
||||
if (process.env.NODE_ENV === 'demo') { return; };
|
||||
const { id } = req.body;
|
||||
try {
|
||||
await db("recipe_steps").where({ recipe_id: id }).del();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue