Knew most of this, but I still watched the entire tutorial because it was so incredibly well structured and didactic. You are a born teacher. I've often fantasized about making great and clear youtube tutorials, in my wildest most perfect fantasies, they looked exactly like the stuff you actually make! Incredible!
I appreciated a lot this free one hour tutorial, I already finish it and I bougth already right now!, I hope the full course is ok and updated!... If you guys want to learn dont hesitate ... watch this video of one hour and when you finish , you'll be more skilled than the before you watched this free course of one hour!.
You are the light of my life! You are a hidden diamond in youtube! I really don't know how a person could be so good at explaining things and make it accessible to all !! Thanks a lot for help.
This is my 3rd time watching a Mosh Tutorial Video starting from React, Node.js, to Express and it has really helped me in my career as an Application Developer. Thanks Mosh!
19:14 below commands for windows, these are case sensitive so use exact VARIABLE name For Command Prompt: set PORT=5000 For Power Shell: $env:port=5000 For Bash (Windows): export PORT=5000
Thank you .. You are the best tutor..... FYI , Joy Validate has made change in 2021, i use this code to resolve my problem of "Joi.validate is not a function". app.post('/api/courses', (req,res) => { const schema = Joi.object({ name: Joi.string().min(3).required() }); const result = schema.validate(req.body); console.log(result);
If you meet the validation error, you have to do some changes to be according with your Joi version. With my Joi version: joi@17.6.0, the next changes worked: const schema = Joi.object({ name: Joi.string() .min(3) .max(30) .required() }); const result = schema.validate(req.body); console.log(result);
As Mosh wisely said to use that specific version of Joi it will work but note that in the current version of Joi you have to make the schema a Joi.object and then at 40:54 validate the schema rather than validate Joi e.g. schema.validate(req.body).
I was struggling learning how to create a server with node and express. This tutorial is really easy to understand and well-structured for beginners. This is so far the best tutorial on RU-vid!!! Thank you so much, Mosh!!!
At 41:00, if using Joi v17, Joi.validate() no longer works. Instead your schema object should be const schema = Joi.object({ name: Joi.string() }); Then use const result = schema.validate(req.body);
I watched your entire Node.Js course which inspired me to change my profile from Angular to Node.js Developer. I have developed 2 apps with ionic/angular & node.js. Thanks to u I could be a full stack developer now.
Mosh you are the man I learned this in my full-stack boot-camp, but didn't fully understand it. Your example was clear concise and helped me understand it better.
Very much dug and appreciated this tutorial. Where as a couple of others I 'learned' things, here I started to actually understand them. That's quite a bit more satisfying!
I appreciated a lot this free one hour tutorial, I already finish it and I bougth already right now!, I hope the full course is ok and updated!... If you guys want to learn dont hesitate ... watch this video of one hour and when you finish , you'll be more skilled than the before you watched this free course of one hour!.
41:17 from v17 of the joi package, here's the updated code of the post route const schema = Joi.object({ name: Joi.string().min(6).required() }); const result = schema.validate(req.body); console.log(result);
Hi, I am using Joi version 17 too. I have problem because Joi.validate or Joi.Object are not recognized functions. Could you help or explain a little bit more? function validateCourse(course){ const schema = Joi.Object({ name: Joi.string().min(3).required() }); return schema.validate(req.body); }
I have solved the problem. I have to use Joi.object and correct parameter. It is working now. Thank you. function validateCourse(course){ const schema = Joi.object({ name: Joi.string().min(3).required() }); return schema.validate(course); }
i just want to thank Mosh for that tutorial. i paid for your course and i'm here to say that it was not a mistake. thank you for your easy to understand courses. i appreciate you
Great tutorial. I had just finished the express course on codecademy and was still really confused. Watching this gave me a much better understanding and explanation of the why and how of building endpoints with express on your actual computer. I'll definitely be checking out your courses and your other videos.
Hi Sir, i took your Angular course... and i made oshop till the end... from then i've been a great fan of you..... never seen such a great teacher.....!!!
For those who missed it in the comment below, Joi has changed. This worked for me: const schema = Joi.object({ name: Joi.string().min(3).required() }); const result = schema.validate(req.body); console.log(result); if (result.error){ res.status(400).send(result.error) }
thankyou mosh , I have been watching API building videos but I had always stuck at routes topic but watching your video I not only have cleared my doubt but also acquired good knowledge
Thank you for your tutorial.. As a starter in Node, I found this really helpful Well structured explanation and good flow for a starter Now I could understand the basic of Node..
you are one of the best teachers i can absorb anything you teach so quickly in just one month i started to work on a big project (+10 k) with react/node + redux and mongoDB , thank you my master
00:49 What are RESTful APIs 06:48 Introducing Express 09:09 Your First Web Server 14:57 Nodemon 16:29 Environment Variables 19:44 Route Parameters 25:22 Handling HTTP GET Requests 30:09 Handling HTTP POST Requests 33:53 Calling APIs using Postman 36:03 Input Validation 44:03 Handling HTTP PUT Requests 52:33 Handling HTTP DELETE Requests
I love his tutorials. If you are using a windows machine, dont use powershell when setting environment variables. rather use cmd because powershell doesnt update the variable until you restart the machine.
A few notes for everybody watching in 2021: // On windows you set environment variables like this: set "$Env:PORT = 5000" //(or maybe without the "" ) // Joi Validation method has changed! it's now like this: const schema = Joi.object({ name: Joi.string().min(3).required(), }); const result = schema.validate(req.body); console.log(result);
This is great! Nicely explained. There are tons of those tutorials in which they just do tons of stuff while telling that they do all this stuff but NOT telling WHY.
Its a great course. I followed it and everything was fine except that when you delete 1 course, the length of the courses decrease. So when you try to add a course after that, it overlaps courses. Anyway, for learning it was excellent! I love it
This is THE cleanest api tutorial I have seen yet! It's just absolutely phenomial! Very well structured and easy to follow. Will be creating a basic orders api, and this will help!
What a great tutorial! I knew most of the content but I watched the entire video because it's so well structured. Congratulations.. Your teaching skills are impressive! I normally skip some parts of most of >20min videos on RU-vid but I watched every little second of this one...
Thank you so much sir for your excellent and detailed explanation of things. I started going through your videos for nodejs and then I have subscribed for the entire course and I cracked 4 interviews as a nodejs developer. Thank you once again for all your effort.
This guy knew everything a long time ago, c++, c#, java, JavaScript, python, PHP et cetera. He knows everything in-depth, he is like a super tech master of all genius.
If anyone was struggle like I was since Joi has been deprecated here's my solution The way I got it to work was first const Joi = require('@hapi/joi'); The way I defined the schema was const schema = Joi.object({ name: Joi.string().min(3).required() }) The way I got it to validate const result = schema.validate(req.body)
I stumbled across this. Can confirm this as working in version 17.1.0. I would highly recommend that if you are using VS Code make sure your intellisense is working. You will see that validate() takes two arguments *value: any* and an optional argument *options?: Joi.ValidationOptions*.
Helpful tip: for setting the environment variable in the "PORT" example, "set PORT=5000" may not work in Windows. $env:PORT = 5000 worked for me instead.
If anyone reads this, please affirm my belief that the logic for post method should be updated now, after the delete method has been written. For eg after deleting the 1st course as mosh did in the lecture, if we call the post method with a valid body, we will create two courses with id = 3(since id of the new course is length of courses plus one). We can change the logic for Initialization of the new course id as the id of the last course object in courses plus one
How do you know what will be returned from the request " require("module_name") " . For example you said require("express") returns a function and require("joi") returns a class. I am wondering where i can find those information.
Excellent question! You'd have to either look at the documentation for the module or explore it yourself, and the easiest way to do that is to run node interactively. Just run node without arguments from the command line, type in the require statement for the module and hit enter. If we're nitpicking, require("joi") returns doesn't return a class but rather an object of the class that it defines.
No, it's just been moved here: hapijs.com/tutorials/validation. If you would've read the page, it says "This module has moved and is now available at @hapi/joi. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues."
There is an issue with your PUT request logic. Let me give you an example. You have the course id's [1, 2, 3]. Then you delete [1]. So you have [2, 3] with length 2. Your PUT assigns the id (length + 1) which is equal to (3), so now you have the course id's [2, 3, 3] so you also need a validiateCourseID() function in order to ensure you don't have duplicate course id's because when calling a GET request on id=3 you will get duplicate results.
Programming with Mosh alright that makes sense. It's just that you taught the course as if we have prior JavaScript knowledge, and hopefully any programmer would have been able to catch a fatal error such as that. Because that would allow you to have lots of duplicate id's.
Okay why at 47:27 gets the whole courses updated when we only have the "course" which we extracted from the courses with the find function Edit: solved
Don't ever just edit some problem you've posted about to say "solved." Share what the solution was so that others who are experiencing the same issue can learn from your question.
It's because of JS nature - whenever you assign some existing object/array to some variable, you actually get the reference to that object/array (not its copy) Check it out yourself in the console let obj1 = {a: 1} let obj2 = obj1 obj2.a = 4 console.log(obj1.a) // 4 That's because it's the same object console.log(obj1 === obj2) Ahh - and also notice that {a: 1} === {a: 1} // false That's because of how JS checks equality of objects
I can't get the PORT environment variable to work on Windows 10... What am I doign wrong? I've tried git bash, powershell and going through the system properties. I've tried $env:PORT, export PORT, set PORT, PORT... Also for some reasons I couldn't get the PUT and DELETE requests to work.
You can use cross-env. It will let you use environment variables across platforms. Accessing process environment variables is always a problem in windows machines. You can simple install it by running the command- npm I cross-env -D Then go to your package.json file inside scripts section you will see the start command, simple replace it with "cross-env PORT=3000 npm start" (Just prepend cross-env before the star command)
This tutorial helped us to solve our problem. Some SDKs we want to use is written in node, but our code base is go. Hence we connect to node to use the SDK and return the result to Go