Conversation
Appilistus
left a comment
There was a problem hiding this comment.
You are doing great job, Julia! :D I left some comments on the codes. I hope it helps!
| } | ||
| } | ||
|
|
||
| // Thought schema |
There was a problem hiding this comment.
For Auth and schema I recommend to create separate files, so that the code will shorter and easy to follow.
routes/thoughtRoutes.js
Outdated
|
|
||
| // Show all thoughts | ||
| router.get("/thoughts", async (req, res) => { | ||
| gi |
There was a problem hiding this comment.
I accidentally started to write git add in the code and it was saved there... It's removed now haha
There was a problem hiding this comment.
Looks simple and clean. Very easy to follow. Good job!
routes/thoughtRoutes.js
Outdated
|
|
||
|
|
||
| // Edit | ||
| router.patch('/thoughts/:id', async (req, res) => { |
There was a problem hiding this comment.
Also here,
router.patch('/thoughts/:id', authenticateUser, async (req, res) => {
| thought.hearts = req.body.hearts ?? thought.hearts; | ||
| await thought.save(); | ||
|
|
||
| return res.json({ success: true, thought }); |
There was a problem hiding this comment.
return HTTP status as well.
res.status(200).json(...)
routes/thoughtRoutes.js
Outdated
|
|
||
|
|
||
| // Post | ||
| router.post("/thoughts", async (req, res) => { |
There was a problem hiding this comment.
I think the code here should be like this:
router.post("/thoughts", authenticateUser, async(req, res) => {...
| password: { type: String, required: true }, | ||
| accessToken: { | ||
| type: String, | ||
| default: () => crypto.randomBytes(128).toString("hex"), |
There was a problem hiding this comment.
In order to use crypto, you need to import crypto from crypto:)
Please include your Render link here.