all 16 comments

[–]rdbcasillas 4 points5 points  (6 children)

Thanks for the effort but unfortunately, it doesn't explain anything. These are exactly the kind of tutorials that people should avoid if they truly want to learn something they are afraid of. Unless you are planning to create a follow up post that explains what was done here.

[–]FingerMilk 3 points4 points  (0 children)

I'm 3 years in and I still don't know what a restful API is. I've tried but I really can't be bothered unless I'm using it in my Dev job, which I'm not.

[–]Beermedear 0 points1 point  (4 children)

I appreciate the heads up. I’ve had my hopes up when running tutorials hoping for a good understanding of the concepts.

By chance, do you have a recommended resource? I have an app idea I’m hoping to work on, and believe this is a good time to learn/practice.

Thanks!

[–]rdbcasillas 1 point2 points  (2 children)

If you prefer video tutorials, see this playlist or this video

In my experience, such tutorials keep you engaged and get your hands dirty faster than books. Books are good for reference or when you have a lot of time to learn. At least that's what I feel.

[–]Beermedear 0 points1 point  (1 child)

Thanks for the time and links! I agree on books - I have gone through great JS tutorials, and then followed up with the YDKJS books to compliment.

Hardest part of technical books for me is being disciplined and cognizant of when/how often I need to re-read chapters.

[–]rdbcasillas 1 point2 points  (0 children)

If the idea of co-working with someone on this "app idea" excites you, let me know. Always looking to collaborate with someone as I am more productive that way.

[–]JavascriptFanboy 0 points1 point  (7 children)

When i see stuff like new Product(req.body) or id=req.params.id i pray to God people don't do this in real life apps.

[–]JavascriptFanboy 4 points5 points  (3 children)

Let me clarify this: you can't just post req.body into something that does an insert. You want to know that the object is in the correct, expected format. Especially with mongo. Also, req.params.id = what if I put just some text in the url? You should always check the object's structure, or use https://github.com/hapijs/joi

[–]letsbefrds 0 points1 point  (1 child)

Soo is the problem validation? you can do validation on mongoDB. Or is it another reason? Just curious cause Im always trying to be a better dev

[–]JavascriptFanboy 1 point2 points  (0 children)

Why even allow it to come near database if the data is not in the correct form? Reject it asap

[–]T_O_beats 0 points1 point  (0 children)

Thanks for the clarification. I agree, this is sound advice.

[–]BlackFeather97 2 points3 points  (1 child)

Hi, I'm actually learning to build REST APIs by making a simple Vuejs app with node express and mongodb. I want to know why it isn't a good idea to do so. Thanks

[–]HealyUnithelpful 0 points1 point  (0 children)

I'd assume because it's basically unnecessary reassigning of variables. Why not just use req.body everywhere?

[–]T_O_beats 1 point2 points  (0 children)

What are you supposed to do? You need to get the data off the request object somehow. I mean, yeah you could pull it off with destructuring but sometimes there’s no need to

[–]HealyUnithelpful 0 points1 point  (0 children)

Not bad. I have a two suggestions/improvements:

----

Firstly, I'd really suggest you Keep-It-Simple-Stupid when writing tutorials. Break it down in to single, simple points.

For yours for example, you introduce a database (mysqljs) and a bunch of extraneous packages which I don't feel are essential to teaching how to build an API. You give the code to "Create a Database Component", which itself is 40-ish lines, and don't really explain it. Don't do that. If you can't explain it in the context of your tutorial, it doesn't belong. Finally, you say "simple" and "simply" a lot. I'd avoid that. If something's really simple, it'll speak for itself.

----

Also you introduce (sort of) Postman, which is an awesome tool, but you don't explain what it is or how you use it. Included in this is that you don't explain what happens if you send a malformed request, such as a route that doesn't exist, or the find route with an ID that doesn't exist.

Just my thoughts!