Skip to content

Comments

API-backend-project#48

Open
julialindstrand wants to merge 34 commits intoTechnigo:masterfrom
julialindstrand:master
Open

API-backend-project#48
julialindstrand wants to merge 34 commits intoTechnigo:masterfrom
julialindstrand:master

Conversation

@julialindstrand
Copy link

Please include your Render link here.

Copy link

@Appilistus Appilistus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are doing great job, Julia! :D I left some comments on the codes. I hope it helps!

}
}

// Thought schema

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Auth and schema I recommend to create separate files, so that the code will shorter and easy to follow.


// Show all thoughts
router.get("/thoughts", async (req, res) => {
gi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gi?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I accidentally started to write git add in the code and it was saved there... It's removed now haha

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks simple and clean. Very easy to follow. Good job!



// Edit
router.patch('/thoughts/:id', async (req, res) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return HTTP status as well.
res.status(200).json(...)



// Post
router.post("/thoughts", async (req, res) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to use crypto, you need to import crypto from crypto:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants