From 1e279840e32bfea414cfc780230db89bd5a4a841 Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Thu, 16 May 2024 16:22:38 +0200 Subject: [PATCH 01/15] Install mongodb and mongoose --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1c371b45..10226ae5 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "@babel/preset-env": "^7.16.11", "cors": "^2.8.5", "express": "^4.17.3", - "mongoose": "^8.0.0", + "mongodb": "^6.6.2", + "mongoose": "^8.3.5", "nodemon": "^3.0.1" } -} \ No newline at end of file +} From 08bf61b2c0bfc10237f11818698351d3198dbc32 Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Thu, 16 May 2024 16:24:58 +0200 Subject: [PATCH 02/15] Install nodemon --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 10226ae5..b0f7a7cd 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,6 @@ "express": "^4.17.3", "mongodb": "^6.6.2", "mongoose": "^8.3.5", - "nodemon": "^3.0.1" + "nodemon": "^3.1.0" } } From 88b1e07eb2551aa992f480174fdd1f40c3b6455c Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Thu, 16 May 2024 16:25:10 +0200 Subject: [PATCH 03/15] Clean up --- server.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server.js b/server.js index dfe86fb8..bc274e96 100644 --- a/server.js +++ b/server.js @@ -6,10 +6,7 @@ const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/project-mongo"; mongoose.connect(mongoUrl); mongoose.Promise = Promise; -// Defines the port the app will run on. Defaults to 8080, but can be overridden -// when starting the server. Example command to overwrite PORT env variable value: -// PORT=9000 npm start -const port = process.env.PORT || 8080; +const port = process.env.PORT || 8000; const app = express(); // Add middlewares to enable cors and json body parsing @@ -18,7 +15,7 @@ app.use(express.json()); // Start defining your routes here app.get("/", (req, res) => { - res.send("Hello Technigo!"); + res.send("Send me a good thought"); }); // Start the server From 5442bd26517ea1615ccd89ccb67123ea77b95db5 Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Thu, 16 May 2024 16:40:18 +0200 Subject: [PATCH 04/15] Add link to deployed version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a75d8e1..c133031d 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,4 @@ Describe how you approached to problem, and what tools and techniques you used t ## View it live -Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about. +[Happy Thoughts RESTful-API](https://technigo-project-happy-thoughts-api.onrender.com/) From 48e272f2b25d95c5a0877e5fa433f75c0d74709c Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Thu, 16 May 2024 17:08:49 +0200 Subject: [PATCH 05/15] Create a schema for thoughts using mongoose --- models/thoughtModel.js | 24 ++++++++++++++++++++++++ server.js | 1 + 2 files changed, 25 insertions(+) create mode 100644 models/thoughtModel.js diff --git a/models/thoughtModel.js b/models/thoughtModel.js new file mode 100644 index 00000000..ed1ad5fc --- /dev/null +++ b/models/thoughtModel.js @@ -0,0 +1,24 @@ +import mongoose from "mongoose"; + +const { Schema } = mongoose; + +const thoughtSchema = new Schema({ + message: { + type: String, + required: true, + minLength: 5, + maxLength: 140, + }, + hearts: { + type: Number, + default: 0, + }, + createdAt: { + type: Date(), + default: () => new Date(), + }, +}); + +export const Thought = mongoose.model("Thought", thoughtSchema); + +// Should not be assignable when creating a new thought diff --git a/server.js b/server.js index bc274e96..fae64089 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,7 @@ import cors from "cors"; import express from "express"; import mongoose from "mongoose"; +import { Thought } from "./models/thoughtModel.js"; const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/project-mongo"; mongoose.connect(mongoUrl); From bd5832da25b26cba6583cb20e0639ae5581500b5 Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Fri, 17 May 2024 12:25:47 +0200 Subject: [PATCH 06/15] Add Thought Model and add new thoughts to the mongdb --- models/thoughtModel.js | 7 +++---- server.js | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/models/thoughtModel.js b/models/thoughtModel.js index ed1ad5fc..22af7739 100644 --- a/models/thoughtModel.js +++ b/models/thoughtModel.js @@ -14,11 +14,10 @@ const thoughtSchema = new Schema({ default: 0, }, createdAt: { - type: Date(), - default: () => new Date(), + type: Date, + // default: () => new Date(), + default: Date.now, }, }); export const Thought = mongoose.model("Thought", thoughtSchema); - -// Should not be assignable when creating a new thought diff --git a/server.js b/server.js index fae64089..b518cde7 100644 --- a/server.js +++ b/server.js @@ -3,7 +3,7 @@ import express from "express"; import mongoose from "mongoose"; import { Thought } from "./models/thoughtModel.js"; -const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/project-mongo"; +const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/thoughts"; mongoose.connect(mongoUrl); mongoose.Promise = Promise; @@ -19,6 +19,40 @@ app.get("/", (req, res) => { res.send("Send me a good thought"); }); +app.get("/thoughts", async (req, res) => { + const thoughts = await Thought.find() + .sort({ createdAt: "desc" }) + .limit(20) + .exec(); + + res.json(thoughts); +}); + +// Routes to add new Thought +app.post("/thoughts", async (req, res) => { + // Promises + // new Thought(req.body) + // .save() + // .then((thought) => { + // res.status(200).json(thought); + // }) + // .catch((err) => { + // res + // .status(400) + // .json({ message: "No new thought was created", err: err.errors }); + // }); + + try { + const { message } = req.body; + const thought = await new Thought({ message }).save(); + res.status(200).json(thought); + } catch (err) { + res + .status(400) + .json({ message: "No new thought was created", err: err.errors }); + } +}); + // Start the server app.listen(port, () => { console.log(`Server running on http://localhost:${port}`); From 51172eb189989afc35f883d23b9b3589cc86817a Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Sat, 18 May 2024 14:58:58 +0200 Subject: [PATCH 07/15] Update hearts value with +1 for each like --- server.js | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/server.js b/server.js index b518cde7..ff7042ae 100644 --- a/server.js +++ b/server.js @@ -30,22 +30,12 @@ app.get("/thoughts", async (req, res) => { // Routes to add new Thought app.post("/thoughts", async (req, res) => { - // Promises - // new Thought(req.body) - // .save() - // .then((thought) => { - // res.status(200).json(thought); - // }) - // .catch((err) => { - // res - // .status(400) - // .json({ message: "No new thought was created", err: err.errors }); - // }); + const { message } = req.body; + const thought = new Thought({ message }); try { - const { message } = req.body; - const thought = await new Thought({ message }).save(); - res.status(200).json(thought); + const savedThought = await thought.save(); + res.status(200).json(savedThought); } catch (err) { res .status(400) @@ -53,6 +43,28 @@ app.post("/thoughts", async (req, res) => { } }); +app.get("/thoughts/:thoughtId/like", async (req, res) => { + // FInd the heart and update its value by one + const { thoughtId } = req.params; + + try { + const thought = await Thought.findById(thoughtId); + + if (!thought) { + return res.status(404).json({ message: "Thought not found" }); + } + + // Update hearts for each like + thought.hearts += 1; + + const updateThought = await thought.save(); + + return res.status(200).json(updateThought); + } catch (err) { + res.status(400).json({ message: "No thought was found", err: err.errors }); + } +}); + // Start the server app.listen(port, () => { console.log(`Server running on http://localhost:${port}`); From 35c75995bb909c7ecadb72e0855fa9d45450bdd1 Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Sun, 19 May 2024 07:46:27 +0200 Subject: [PATCH 08/15] Comment out parts of code to test db connection --- server.js | 75 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/server.js b/server.js index ff7042ae..9202d42b 100644 --- a/server.js +++ b/server.js @@ -19,51 +19,52 @@ app.get("/", (req, res) => { res.send("Send me a good thought"); }); -app.get("/thoughts", async (req, res) => { - const thoughts = await Thought.find() - .sort({ createdAt: "desc" }) - .limit(20) - .exec(); +// app.get("/thoughts", async (req, res) => { +// const thoughts = await Thought.find() +// .sort({ createdAt: "desc" }) +// .limit(20) +// .exec(); - res.json(thoughts); -}); +// res.json(thoughts); -// Routes to add new Thought -app.post("/thoughts", async (req, res) => { - const { message } = req.body; - const thought = new Thought({ message }); - - try { - const savedThought = await thought.save(); - res.status(200).json(savedThought); - } catch (err) { - res - .status(400) - .json({ message: "No new thought was created", err: err.errors }); - } -}); +// }); -app.get("/thoughts/:thoughtId/like", async (req, res) => { - // FInd the heart and update its value by one - const { thoughtId } = req.params; +// // Routes to add new Thought +// app.post("/thoughts", async (req, res) => { +// const { message } = req.body; +// const thought = new Thought({ message }); - try { - const thought = await Thought.findById(thoughtId); +// try { +// const savedThought = await thought.save(); +// res.status(200).json(savedThought); +// } catch (err) { +// res +// .status(400) +// .json({ message: "No new thought was created", err: err.errors }); +// } +// }); - if (!thought) { - return res.status(404).json({ message: "Thought not found" }); - } +// app.get("/thoughts/:thoughtId/like", async (req, res) => { +// // FInd the heart and update its value by one +// const { thoughtId } = req.params; - // Update hearts for each like - thought.hearts += 1; +// try { +// const thought = await Thought.findById(thoughtId); - const updateThought = await thought.save(); +// if (!thought) { +// return res.status(404).json({ message: "Thought not found" }); +// } - return res.status(200).json(updateThought); - } catch (err) { - res.status(400).json({ message: "No thought was found", err: err.errors }); - } -}); +// // Update hearts for each like +// thought.hearts += 1; + +// const updateThought = await thought.save(); + +// return res.status(200).json(updateThought); +// } catch (err) { +// res.status(400).json({ message: "No thought was found", err: err.errors }); +// } +// }); // Start the server app.listen(port, () => { From b7920cf428ce4a79e00348f7a232146f7a739cdd Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Sun, 19 May 2024 08:06:35 +0200 Subject: [PATCH 09/15] Comment out parts of code to test db connection --- server.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/server.js b/server.js index 9202d42b..0db626e4 100644 --- a/server.js +++ b/server.js @@ -3,10 +3,6 @@ import express from "express"; import mongoose from "mongoose"; import { Thought } from "./models/thoughtModel.js"; -const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/thoughts"; -mongoose.connect(mongoUrl); -mongoose.Promise = Promise; - const port = process.env.PORT || 8000; const app = express(); @@ -14,6 +10,25 @@ const app = express(); app.use(cors()); app.use(express.json()); +const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/thoughts"; +mongoose + .connect(mongoUrl) + .then(() => { + console.log("App is conntected to db"); + // Start the server when conntected to db + app.listen(port, () => { + console.log(`Server running on http://localhost:${port}`); + }); + }) + .catch((err) => { + console.log(err); + }); +mongoose.Promise = Promise; + +// const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/thoughts"; +// mongoose.connect(mongoUrl); +// mongoose.Promise = Promise; + // Start defining your routes here app.get("/", (req, res) => { res.send("Send me a good thought"); @@ -67,6 +82,6 @@ app.get("/", (req, res) => { // }); // Start the server -app.listen(port, () => { - console.log(`Server running on http://localhost:${port}`); -}); +// app.listen(port, () => { +// console.log(`Server running on http://localhost:${port}`); +// }); From 0b0f93ba588fa82a913b6360217fed041e053222 Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Sun, 19 May 2024 18:31:37 +0200 Subject: [PATCH 10/15] Add thoughts route to get all data --- server.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/server.js b/server.js index 0db626e4..00e6c1e2 100644 --- a/server.js +++ b/server.js @@ -34,15 +34,14 @@ app.get("/", (req, res) => { res.send("Send me a good thought"); }); -// app.get("/thoughts", async (req, res) => { -// const thoughts = await Thought.find() -// .sort({ createdAt: "desc" }) -// .limit(20) -// .exec(); +app.get("/thoughts", async (req, res) => { + const thoughts = await Thought.find() + .sort({ createdAt: "desc" }) + .limit(20) + .exec(); -// res.json(thoughts); - -// }); + res.json(thoughts); +}); // // Routes to add new Thought // app.post("/thoughts", async (req, res) => { From 8835725acc5b42a5e816d914ff0fba6ce3c74103 Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Sun, 19 May 2024 18:43:03 +0200 Subject: [PATCH 11/15] Add thoughts route to get all data --- server.js | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/server.js b/server.js index 00e6c1e2..047b4293 100644 --- a/server.js +++ b/server.js @@ -3,6 +3,10 @@ import express from "express"; import mongoose from "mongoose"; import { Thought } from "./models/thoughtModel.js"; +const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/thoughts"; +mongoose.connect(mongoUrl); +mongoose.Promise = Promise; + const port = process.env.PORT || 8000; const app = express(); @@ -10,25 +14,6 @@ const app = express(); app.use(cors()); app.use(express.json()); -const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/thoughts"; -mongoose - .connect(mongoUrl) - .then(() => { - console.log("App is conntected to db"); - // Start the server when conntected to db - app.listen(port, () => { - console.log(`Server running on http://localhost:${port}`); - }); - }) - .catch((err) => { - console.log(err); - }); -mongoose.Promise = Promise; - -// const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/thoughts"; -// mongoose.connect(mongoUrl); -// mongoose.Promise = Promise; - // Start defining your routes here app.get("/", (req, res) => { res.send("Send me a good thought"); @@ -81,6 +66,6 @@ app.get("/thoughts", async (req, res) => { // }); // Start the server -// app.listen(port, () => { -// console.log(`Server running on http://localhost:${port}`); -// }); +app.listen(port, () => { + console.log(`Server running on http://localhost:${port}`); +}); From 57d868923fc1b7cac2964cde96cf4cf8f60855e6 Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Sun, 19 May 2024 18:47:43 +0200 Subject: [PATCH 12/15] Testing connection --- models/thoughtModel.js | 4 +-- server.js | 56 +++++------------------------------------- 2 files changed, 8 insertions(+), 52 deletions(-) diff --git a/models/thoughtModel.js b/models/thoughtModel.js index 22af7739..bbe5894c 100644 --- a/models/thoughtModel.js +++ b/models/thoughtModel.js @@ -15,8 +15,8 @@ const thoughtSchema = new Schema({ }, createdAt: { type: Date, - // default: () => new Date(), - default: Date.now, + default: () => new Date(), + // default: Date.now, }, }); diff --git a/server.js b/server.js index 047b4293..dfe86fb8 100644 --- a/server.js +++ b/server.js @@ -1,13 +1,15 @@ import cors from "cors"; import express from "express"; import mongoose from "mongoose"; -import { Thought } from "./models/thoughtModel.js"; -const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/thoughts"; +const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/project-mongo"; mongoose.connect(mongoUrl); mongoose.Promise = Promise; -const port = process.env.PORT || 8000; +// Defines the port the app will run on. Defaults to 8080, but can be overridden +// when starting the server. Example command to overwrite PORT env variable value: +// PORT=9000 npm start +const port = process.env.PORT || 8080; const app = express(); // Add middlewares to enable cors and json body parsing @@ -16,55 +18,9 @@ app.use(express.json()); // Start defining your routes here app.get("/", (req, res) => { - res.send("Send me a good thought"); + res.send("Hello Technigo!"); }); -app.get("/thoughts", async (req, res) => { - const thoughts = await Thought.find() - .sort({ createdAt: "desc" }) - .limit(20) - .exec(); - - res.json(thoughts); -}); - -// // Routes to add new Thought -// app.post("/thoughts", async (req, res) => { -// const { message } = req.body; -// const thought = new Thought({ message }); - -// try { -// const savedThought = await thought.save(); -// res.status(200).json(savedThought); -// } catch (err) { -// res -// .status(400) -// .json({ message: "No new thought was created", err: err.errors }); -// } -// }); - -// app.get("/thoughts/:thoughtId/like", async (req, res) => { -// // FInd the heart and update its value by one -// const { thoughtId } = req.params; - -// try { -// const thought = await Thought.findById(thoughtId); - -// if (!thought) { -// return res.status(404).json({ message: "Thought not found" }); -// } - -// // Update hearts for each like -// thought.hearts += 1; - -// const updateThought = await thought.save(); - -// return res.status(200).json(updateThought); -// } catch (err) { -// res.status(400).json({ message: "No thought was found", err: err.errors }); -// } -// }); - // Start the server app.listen(port, () => { console.log(`Server running on http://localhost:${port}`); From 4693e4bfc97a7201f78df72a705a8b01183a6414 Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Tue, 21 May 2024 07:27:41 +0200 Subject: [PATCH 13/15] Testing connection --- server.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index dfe86fb8..047b4293 100644 --- a/server.js +++ b/server.js @@ -1,15 +1,13 @@ import cors from "cors"; import express from "express"; import mongoose from "mongoose"; +import { Thought } from "./models/thoughtModel.js"; -const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/project-mongo"; +const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/thoughts"; mongoose.connect(mongoUrl); mongoose.Promise = Promise; -// Defines the port the app will run on. Defaults to 8080, but can be overridden -// when starting the server. Example command to overwrite PORT env variable value: -// PORT=9000 npm start -const port = process.env.PORT || 8080; +const port = process.env.PORT || 8000; const app = express(); // Add middlewares to enable cors and json body parsing @@ -18,9 +16,55 @@ app.use(express.json()); // Start defining your routes here app.get("/", (req, res) => { - res.send("Hello Technigo!"); + res.send("Send me a good thought"); }); +app.get("/thoughts", async (req, res) => { + const thoughts = await Thought.find() + .sort({ createdAt: "desc" }) + .limit(20) + .exec(); + + res.json(thoughts); +}); + +// // Routes to add new Thought +// app.post("/thoughts", async (req, res) => { +// const { message } = req.body; +// const thought = new Thought({ message }); + +// try { +// const savedThought = await thought.save(); +// res.status(200).json(savedThought); +// } catch (err) { +// res +// .status(400) +// .json({ message: "No new thought was created", err: err.errors }); +// } +// }); + +// app.get("/thoughts/:thoughtId/like", async (req, res) => { +// // FInd the heart and update its value by one +// const { thoughtId } = req.params; + +// try { +// const thought = await Thought.findById(thoughtId); + +// if (!thought) { +// return res.status(404).json({ message: "Thought not found" }); +// } + +// // Update hearts for each like +// thought.hearts += 1; + +// const updateThought = await thought.save(); + +// return res.status(200).json(updateThought); +// } catch (err) { +// res.status(400).json({ message: "No thought was found", err: err.errors }); +// } +// }); + // Start the server app.listen(port, () => { console.log(`Server running on http://localhost:${port}`); From 26094e8096271c333d4a78797da616a4fc9aeae0 Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Tue, 21 May 2024 07:39:26 +0200 Subject: [PATCH 14/15] Testing connection --- server.js | 58 +++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/server.js b/server.js index 047b4293..ff7042ae 100644 --- a/server.js +++ b/server.js @@ -28,42 +28,42 @@ app.get("/thoughts", async (req, res) => { res.json(thoughts); }); -// // Routes to add new Thought -// app.post("/thoughts", async (req, res) => { -// const { message } = req.body; -// const thought = new Thought({ message }); +// Routes to add new Thought +app.post("/thoughts", async (req, res) => { + const { message } = req.body; + const thought = new Thought({ message }); -// try { -// const savedThought = await thought.save(); -// res.status(200).json(savedThought); -// } catch (err) { -// res -// .status(400) -// .json({ message: "No new thought was created", err: err.errors }); -// } -// }); + try { + const savedThought = await thought.save(); + res.status(200).json(savedThought); + } catch (err) { + res + .status(400) + .json({ message: "No new thought was created", err: err.errors }); + } +}); -// app.get("/thoughts/:thoughtId/like", async (req, res) => { -// // FInd the heart and update its value by one -// const { thoughtId } = req.params; +app.get("/thoughts/:thoughtId/like", async (req, res) => { + // FInd the heart and update its value by one + const { thoughtId } = req.params; -// try { -// const thought = await Thought.findById(thoughtId); + try { + const thought = await Thought.findById(thoughtId); -// if (!thought) { -// return res.status(404).json({ message: "Thought not found" }); -// } + if (!thought) { + return res.status(404).json({ message: "Thought not found" }); + } -// // Update hearts for each like -// thought.hearts += 1; + // Update hearts for each like + thought.hearts += 1; -// const updateThought = await thought.save(); + const updateThought = await thought.save(); -// return res.status(200).json(updateThought); -// } catch (err) { -// res.status(400).json({ message: "No thought was found", err: err.errors }); -// } -// }); + return res.status(200).json(updateThought); + } catch (err) { + res.status(400).json({ message: "No thought was found", err: err.errors }); + } +}); // Start the server app.listen(port, () => { From 217b56b693a85ee91bc40d8b90d15bd16eb02cff Mon Sep 17 00:00:00 2001 From: Pernilla Sterner Date: Tue, 21 May 2024 08:02:22 +0200 Subject: [PATCH 15/15] Add patch to update likes --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index ff7042ae..b6ff1827 100644 --- a/server.js +++ b/server.js @@ -43,7 +43,7 @@ app.post("/thoughts", async (req, res) => { } }); -app.get("/thoughts/:thoughtId/like", async (req, res) => { +app.patch("/thoughts/:thoughtId/like", async (req, res) => { // FInd the heart and update its value by one const { thoughtId } = req.params;