This one took a few energy drinks to make! Hope you guys enjoy it! I also left some timestamps in the description if you want to jump around or come back to the tutorial easily!
if you got this error -> "TypeError: Joi.validate is not a function" at min 29:00 or so, fix this by writing "schema.validate(req.body);" instead of "Joi.validate(req.body, schema);"
bro. BRO. i was stuck on that for fucking 3 HOURSSSS. FML. I had such a fucking headache. i was like whyyyy, WHYYYYYYY DOES THIS ONT WORK. you saved me, and my brain.
I agree with you.. His voice is so clear and explanation is very short and what i need that. If i need a full explanation i will look up into documentation
around minute 18:40 => is better to use a timestamps instead of putting a property date when you create a Schema, example: UserSchema = new mongoose.Schema({property:{ }}, {timestamps: true}). In this way it creates a createdAt and updateAt and it automatically updates it.
I already knew Angular and I was holding myself back from creating a MEAN Application. I wanted to get started by creating a basic application. I came across your Rest API tutorial and created one simple notes app using angular. Then I wanted to have authentication in my app so I saw this video and trust me you have kept it so simple as compared to other overrated tutorials out there.You are a life saver. Would've loved if you had a second part to this where you consume this API and create a front end for it.
I must say, this is the best tutorial I have ever seen for explaining about JWT tokens. Honestly, by watching this video, I learned more than what they taught in the Bootcamp. I became a huge fan of you, DevEd. Your explanation is so so good. The jokes you make in between helps people a lot for not getting bored, and to concentrate more. The end is: I started loving your tutorials.
After two udemy courses, endless stackoverflow reads and about twenty youtube videos on jwt, I have to admit that I never saw such a clear (hands-on) explanation as this one --> 56:19. Thank you a ton Ed!
Joi changed their documentation and you'll need to create the schema as such- const schema = Joi.object({ // name, email etc.. }); and then you'll destructure the error as const {error} = schema.validate(req.body); hope this helps :)
You are such a talented teacher. I'v been at University for 5 years and honestly, the "learnings/hour" in your content is making Uni look like a playground.
Things covered in this video: 00:00:57 Introduction 00:02:32 Setting up express 00:08:12 Connecting to a database 00:14:22 .env files 00:16:39 Creating models in mongoose 00:19:34 Registering a user 00:25:40 Validation with Joi 00:42:35 Hashing passwords 00:48:53 Setting up the login route 00:57:25 Adding jsonwebtokens to our auth 01:03:25 Creating private routes with jwt Copied from the description.
The thing with all these guides in here, is that people never explain how to use different packages and libraries together. You are the one who explains them and also combine them in a way other people will use them in real life. I am kinda new in Js and most things don't actually fit together just by doing random research. Thank you. I really hope you do a tutorial with mysql DB for people like myself who are new in this and mysql is the first step in dbs
Hey Ed! Glad you're not completely burned out of development videos 😄thanks for inspiring people, you inspired me to start creating similar videos too!
Hello, For new version of Joi, "Joi.validate(req.body, schema); " throws error. The solution is: "const schema = Joi.object({ name: Joi.string().min(6). required (), email: Joi.string().min(6). required (), password: Joi.string().min(6). required () });" Then in post route: " const validation= schema.validate(req.body); res.send(validation); " this will solve the error...
nearly all youtuber developer teachers teaching low or beginner levels developing but you are teaching like a expert an again thanks for your sharing I learned from you
It's my first time using node.js, mongodb and everything discussed on this video and i find it very easy, and it's because of you! Great tutorial, thank you! :D
Best wishes n good blessings from India Dev Ed . I saw your previous videos of nodejs , now I can say that , yeah I am familiar with node-js . The concept of middleware was not clear to me but u made it very easy to me . All I want say that .....U are a savior n a very rare human being who have outstanding teaching capabilities .
I just wanted to say...Thank you so much! I finally understand how tokens are sent to the headers and are used. I've watched countless videos and read blogs, articles, and docs, none of them explained that particular part very well! Keep it up, dude!
Hello everyone. Due to the age of the video there is some changes with Joi which you will come to with the error Joi.validate is not a function" at min 29:00. First of all Hapi Joi is deprecated so you will want to npm install 'joi' instead. Also with creating the schema it will look like this: const schema = Joi.object({ .. as per video ..}); . Then validate the schema via const {error} = schema.validate(req.body);
@@ventifan1018 You must needed to chage joi to Joi, with caps const schema = joi.object({ name: Joi.string().min(6).required(), email: Joi.string().min(6).required().email(), password: Joi.string().min(6).required() });
What I love about your videos is that you always start over from scratch. I think learning is repetitions so it helps me to remember informations better than the last time I watch one of your video! Thanks!
On 30:28, joi happened to update so it wont work as shown in the video instead use const schema = Joi.object({ name: Joi.string().min(6).required(), email: Joi.string().min(6).email().required(), password: Joi.string().min(5).required(), }); //and const validation = schema.validate(req.body); //in the router.post("/register") method
Complete!!! God!!! you are a lifesaver dude!!! 4 years old video yet a super helpful and reliable channel for beginners like me!!! Liked, Shared, Subscribed and also presses the bell icon!!!
Super complete tutorial that I will be recommending to my peers starting their dev careers! As feedback, would be great if you split the video chapters directly (I saw there is a an index of content by the minute in the description though. Informative and concise tut Ed!
I've watched a lot of tutorials that ended up confusing me more on NodeJS. But this right here, i the best i have come across. Seeing how you even explained what each operation does. You just init my backend career lol. Thank you
Hey, very useful video! A quick notice, min and max properties on the mongoose Schema should instead be minlength and maxlength respectively. The reason is that min and max refer to the exact values, number or date. Like if we have { min: 2 } an input of 3 will not be allowed. Instead we care about the length of the input and not the value. Hope that helps. Correct me if I am wrong.
Wow.... what can I say? Spending more than an hour and get the nice things I am looking for. Thanks and thank you very much. Simple but covers all. Great effort my bro....
First, let me start by saying i appreciate the energy and effort into making these tutorials and sharing them for free that should never be taking for granted so thank you yet i was expecting it to be JWT focused since that's mainly in the title but you only start using it around 58:00 i do understand this topic involves a lot of boilerplate to demonstrate
It would be a great FAVOR if you can do another VIDEO which help with UNIT TEST like how we can integrate UNIT testing using JEST for this login app OR any node app
For those running in to a Joi.validate issue ~28:00, Joi.validate is no longer a function and instead you turn the schema object in to a const schema = Joi.object({username: blahblah...}) and then run schema.validate(req.body) instead of Joi.validate(req.body, schema)
Finally this video came as a savior for me. Thanks Dev Ed 💖 Also, if someone is watching in 2021, schema.validate() is the new function instead of Joi.validate() here is the code you might stuck at-> //Register validation const registerValidation = (data) => { const schema = Joi.object({ name: Joi.string().min(6).required(), email: Joi.string().min(6).required().email(), password: Joi.string().min(6).required(), }); return schema.validate(data); };
Hi Dev i've a problem.. when i send the /register request from postman, the server stops at "await user.save()" (without any response).. (i think is a mongodb user problem... but i created also another account with reading and writing privileges..)
Great tutorial but having an issue saving to the database. Everything else works as expected, my db connection, user model is correct when logged to console, but if I add async and await it hangs then gives an error in postman. Do I need to manually create a collection in Atlas before? Any ideas, been trying to fix this for hours and getting fed up as followed this video word for word in my code :( try { const savedUser = await user.save(); res.send(savedUser); } catch (err) { res.status(400).send(err); }
Really Nice work man! It helped me a lot to understand auth with json. Thanks. What about a frontend for this login, and if the user is valid, we redirect him to a page with the transition (using jsx, styled components, etc) from the last video.
This tut is beautiful. It chronologically tells me what all needs to be taken care of during setting up auth. I always used to get confused with the chronology.
if you end up sending the name, email, password from an actual HTML form (browser), you will need: app.use(express.urlencoded({ extended: true })) in the index.js file.
Can you show you you did this? I am trying to do this same thing but I have no idea how to implement my html file. gitrepo or contact me please g.jonathan252@gmail.com
Wow!! you explain things so seamlessly, feel great to learn things, so I hit that subscribe button, guess i will learn lot more on nodejs from this channel, love it
Thanks Dev Ed this help me lot !!!! If anyone facing error at 29:00 as joi.validate() is not a function just type instead schema.validate(req.body) but before this create const schema = joi.object({...../*and create here validation schema*/....})
The new version of Joi requires validation to be written like this: const schema = Joi.object({ name: Joi.string() .min(6) .required(), email: Joi.string() .min(6) .required() .email(), password: Joi.string() .min(6) .required() }); const validation = schema.validate(req.body); res.send(validation.error.details[0].message);
im not being able to make it work when the validation is in another file, i can avoid any error returning schema.validate(data) instead of Joi.validate(data, schema), but its not actually apllying the validation. Any tip?
@@ShikaNiots i was facing the same issue, got it to work with removing schema param from the return in the validation.js file using the updated joi documentation. e.g. "return schema.validata(data);"
I always like your videos because of how you kick them off, I'm usually serious when looking for such content and i highly appreciate you making me laugh!
@@kattenelvis1778 Can't stand it. The startup company I'm working in wanted me to write their microservices in React. I said I'd quit if they forced me to write React, so they changed their mind. I know use the MEVN stack on all their microservices, and the other developers on the team love me for that xd
Great tut, he really has a way to breaking down things! I like that he focuses on the 'matter' on hand, and what doesn't and can waste time (like waste time making actual forms, he has other tuts for that that) and most importantly, like his other tuts, he puts all those concepts / libraries / tools into perspective allowing you to understand how they all relate.
If anyone is having issues with connecting to the database, you need to first create a database and the collection on the mongodb page at 12:24 when he get the url it only appears the that needs to be changed into the user password, but in my case it also had a after the .net and there you have to put the name of the database you created, he used a database called test
amazing video - the only update needed that I can see is Joi changed their syntax so now you need to write it the following way: const schema = Joi.object({ email: Joi.string().min(6).required().email(), password: Joi.string().min(6).required(), }); return schema.validate(data);
If you don't know anything about RESTful APIs and you don't wanna waste precious time of yours then do not skip even a second of this video and you'll be just like me(who knew nothing how to code RESTful APIs) who can code RESTful APIs damn easily now💯💕 Your time and efforts are much appreciated Ed!
You did an amazing job. I get this a lot better now! One thing I wished was that you’d explain more about what a middleware was more in depth. But, I’m in a web dev elective in my CS program right now so I kinda already knew! Needless to say, you did a killer job. You moved faster than a super slow beginning tutorial but not too fast that no one would understand. Thank you !
@@developedbyed Would be very grateful if u could make something related to e-commerce/shopping cart from scratch (both the client and server) which is very in demand now. Other tutorials nowadays just suck as they give us many basic things and less real scenarios. They don't visualize the way to dive into these patterns as u do.
First of all, I love your energy. Make me more excited to learn. I plan of mastering node.js (express) to become a back end dev and secure a proper job. Wish me luck. Thank you so much.
I love the way u make Videos it's really relaxing and at the same time provides me knowledge. I have to say that there are few people i meet in my life journey of 20 who teaches so beautifully like you.Thank you for all you have done for the community
VERY WELL presented! You presented jwt's and mongo access, api routes, etc. in a very easy to follow manner. Now, I need to go back and implement this in a project as I watch and follow along again so that it sinks in to my squishy brain. :)
Dude I saw like 3 JWT tutorials before this one, but my face was like WTF! then I came here and I now have a very good understanding of it!!! thanks a lot!!!!
Really fun learning with you. I'm new to all this nodejs + mongo + everything else (old guy that worked on Oracle all his life) :) And you are teaching at the perfect speed!
Course is so great but part 46:03 joi function 'validate' is no longer supported in that fashion, use ==> //VALIDATION const Joi = require("joi"); const Validateschema = Joi.object({ fullname: Joi.string().min(6).required(), email: Joi.string().min(6).required(), password: Joi.string().min(5).required(), }); router.post("/enroll", async (req, res) => { const validate = Validateschema.validate(req.body); res.send(validate); Thanks.
OMG I have never ever learnt so much as I have done in this course wow So engaging, entertaining and full of useful information!!! Anyone reading highly RECOMMENDED!! Could you do tutorial where you build a basic like backend system that post stuff to like the front end :)
I had to rewind that magic trick about 10 times. It made my day, thank you :D
playspeed 0.25 :D
Yeah it helps 😊
I did the same, with 0.25 speed
use like that
const schema = Joi.object({
name: Joi.string().min(6).required(),
email: Joi.string().min(6).required().email(),
password: Joi.string().min(6).required(),
});
return schema.validate(req);
@@gihanrangana6248 What do that
This one took a few energy drinks to make! Hope you guys enjoy it! I also left some timestamps in the description if you want to jump around or come back to the tutorial easily!
Thx Ed
very useful content bro! but can you share the code with us please ?
appreciate super like
very usefuly but can you do a tutorial for mysql for us please ??? thanks dear
Hi, Dev I would like to find a direct link for the code in the description if you don't mind :)
if you got this error -> "TypeError: Joi.validate is not a function" at min 29:00 or so, fix this by writing
"schema.validate(req.body);" instead of "Joi.validate(req.body, schema);"
and setup the schema as: const schema = Joi.object({...});
I need to look at comments first next time)))
bro. BRO. i was stuck on that for fucking 3 HOURSSSS. FML. I had such a fucking headache. i was like whyyyy, WHYYYYYYY DOES THIS ONT WORK. you saved me, and my brain.
a true hero, thank you
you're a Godsend
People still spending money for bad tutorials, while you can find the best one on RUclips.
Great tutorial! 👌🏻
True.
I agree with you.. His voice is so clear and explanation is very short and what i need that. If i need a full explanation i will look up into documentation
Yep, this true
totally true
agree, u never get bored while following his videos
"Life is wonderful when things work." - DevEd, 2019
Literally, I will make it make my Whatsapp status and Insta bio
wtf
@@codingdaily4094 😂😂 I Love DevEd
Wise genius words
i was also drinking water when he said that DDdd
around minute 18:40 => is better to use a timestamps instead of putting a property date when you create a Schema, example: UserSchema = new mongoose.Schema({property:{ }}, {timestamps: true}). In this way it creates a createdAt and updateAt and it automatically updates it.
Something very good to know
@@fedus22 I agree
thank you random programmer!
good idea
Then we should probably change the name to 'Last updated date' instead of Date
I already knew Angular and I was holding myself back from creating a MEAN Application. I wanted to get started by creating a basic application. I came across your Rest API tutorial and created one simple notes app using angular. Then I wanted to have authentication in my app so I saw this video and trust me you have kept it so simple as compared to other overrated tutorials out there.You are a life saver. Would've loved if you had a second part to this where you consume this API and create a front end for it.
I must say, this is the best tutorial I have ever seen for explaining about JWT tokens. Honestly, by watching this video, I learned more than what they taught in the Bootcamp. I became a huge fan of you, DevEd. Your explanation is so so good. The jokes you make in between helps people a lot for not getting bored, and to concentrate more. The end is: I started loving your tutorials.
After two udemy courses, endless stackoverflow reads and about twenty youtube videos on jwt, I have to admit that I never saw such a clear (hands-on) explanation as this one --> 56:19. Thank you a ton Ed!
Joi changed their documentation and you'll need to create the schema as such-
const schema = Joi.object({
// name, email etc..
});
and then you'll destructure the error as const {error} = schema.validate(req.body);
hope this helps :)
thanks for help
thanks Zach!
Thank you for saving me from nightmare
You saved my day dude.
Thanks bro😄
You are such a talented teacher. I'v been at University for 5 years and honestly, the "learnings/hour" in your content is making Uni look like a playground.
I quit college nevermind uni
Things covered in this video:
00:00:57 Introduction
00:02:32 Setting up express
00:08:12 Connecting to a database
00:14:22 .env files
00:16:39 Creating models in mongoose
00:19:34 Registering a user
00:25:40 Validation with Joi
00:42:35 Hashing passwords
00:48:53 Setting up the login route
00:57:25 Adding jsonwebtokens to our auth
01:03:25 Creating private routes with jwt
Copied from the description.
@DevEd, if you put 0:00:00 Start in the description you will get hotspots on the video
The thing with all these guides in here, is that people never explain how to use different packages and libraries together. You are the one who explains them and also combine them in a way other people will use them in real life. I am kinda new in Js and most things don't actually fit together just by doing random research. Thank you. I really hope you do a tutorial with mysql DB for people like myself who are new in this and mysql is the first step in dbs
Hey Ed! Glad you're not completely burned out of development videos 😄thanks for inspiring people, you inspired me to start creating similar videos too!
Hello,
For new version of Joi,
"Joi.validate(req.body, schema); " throws error.
The solution is:
"const schema = Joi.object({
name: Joi.string().min(6). required (),
email: Joi.string().min(6). required (),
password: Joi.string().min(6). required ()
});"
Then in post route:
"
const validation= schema.validate(req.body);
res.send(validation);
"
this will solve the error...
thank you :)
helped a lot thank you :)
Hey buddy, can you help me with this? "message": "\"name\" failed custom validation because Cannot read property 'presence' of undefined",
thank you, buddy, I just posted a comment that I had this problem but then I found your comment. When I tried it, it was working. I really thank you.
and what about at 36:43? im just not an expert at node.js
nearly all youtuber developer teachers teaching low or beginner levels developing but you are teaching like a expert an again thanks for your sharing I learned from you
For anyone struggling with the string length validation, you should use minLength / maxLength for strings rather than min / max which is for numbers
TYSM, so helpful
This channel is criminally under subbed. Keep up the good work, love your content!
video 1:15 hours - my view time 4 hours - my script is running- Thank you so much doing the tutorial
Idk how randomly i found your channel but I'm glad i did... :)
It's my first time using node.js, mongodb and everything discussed on this video and i find it very easy, and it's because of you! Great tutorial, thank you! :D
Literally one of my fav Tubers at the moment. Can't wait to see your success 😏
Best wishes n good blessings from India Dev Ed . I saw your previous videos of nodejs , now I can say that , yeah I am familiar with node-js . The concept of middleware was not clear to me but u made it very easy to me . All I want say that .....U are a savior n a very rare human being who have outstanding teaching capabilities .
Hahahaha! That magic trick got me pumped up for the rest of the tutorial! Thanks, @Dev Ed. You are unique in an amazing way.
trueee
whenever I watch his videos he always put smile on my face. He is one of the best teacher for programming available on youtube!
As of npm 5.0.0, installed modules are added as a dependency by default, so the --save option is no longer needed
Correct!
@@developedbyed thanks for the tutorial you covered pretty much everything related to node :)
I just wanted to say...Thank you so much! I finally understand how tokens are sent to the headers and are used. I've watched countless videos and read blogs, articles, and docs, none of them explained that particular part very well! Keep it up, dude!
Hello everyone. Due to the age of the video there is some changes with Joi which you will come to with the error Joi.validate is not a function" at min 29:00. First of all Hapi Joi is deprecated so you will want to npm install 'joi' instead. Also with creating the schema it will look like this: const schema = Joi.object({ .. as per video ..}); . Then validate the schema via const {error} = schema.validate(req.body);
const router = require('express').Router();
const User = require('../model/User');
//Validation
const Joi = require('@hapi/joi');
const schema = joi.object({
name: Joi.string().min(6).required(),
email: Joi.string().min(6).required().email(),
password: Joi.string().min(6).required()
});
router.post('/register', async (req,res) => {
//Lets validate the data before we are user
const {error} = schema.validate(req.body);
res.send(error.details[0].message);
// const user = new User({
// name: req.body.name,
// email: req.body.email,
// password: req.body.password
// });
// try{
// const savedUser = await user.save();
// res.send(savedUser);
// }catch(err){
// res.status(400).send(err);
// }
});
@@ventifan1018 You must needed to chage joi to Joi, with caps
const schema = joi.object({
name: Joi.string().min(6).required(),
email: Joi.string().min(6).required().email(),
password: Joi.string().min(6).required()
});
@@RicardoDanyalgilJunior Thanks man!!
When I saw that Borsec bottle I knew this was gonna be the best tutorial I could find on the web , thank you so much ! :))
Oh man, you don't know how much i've been waiting for this, such an amazing video with lots of fun code, BIG THANKS :)
What I love about your videos is that you always start over from scratch. I think learning is repetitions so it helps me to remember informations better than the last time I watch one of your video! Thanks!
Next part maybe create a front-end to this?
Good Idea
YESSSSS.
hell yeah
@@sunnyparmar9692 yes please we need the front end to this maby with user / admin section
Absolutely necessary, please do it Ed!
I wish all tuts over Internet were this deep and condensed. This was pure gold. Thanks
On 30:28, joi happened to update so it wont work as shown in the video instead use
const schema = Joi.object({
name: Joi.string().min(6).required(),
email: Joi.string().min(6).email().required(),
password: Joi.string().min(5).required(),
});
//and
const validation = schema.validate(req.body);
//in the router.post("/register") method
Can you do a second part to this? Like how to add the front end part? (like a login page, sign in, etc)...
yes please
Hey, did you find anywhere tutorial with front part?
Guys check out his frontend course you might find something there
Complete!!! God!!! you are a lifesaver dude!!! 4 years old video yet a super helpful and reliable channel for beginners like me!!! Liked, Shared, Subscribed and also presses the bell icon!!!
Super complete tutorial that I will be recommending to my peers starting their dev careers!
As feedback, would be great if you split the video chapters directly (I saw there is a an index of content by the minute in the description though. Informative and concise tut Ed!
I've watched a lot of tutorials that ended up confusing me more on NodeJS. But this right here, i the best i have come across.
Seeing how you even explained what each operation does.
You just init my backend career lol.
Thank you
Hey, very useful video!
A quick notice, min and max properties on the mongoose Schema should instead be minlength and maxlength respectively. The reason is that min and max refer to the exact values, number or date. Like if we have { min: 2 } an input of 3 will not be allowed. Instead we care about the length of the input and not the value.
Hope that helps. Correct me if I am wrong.
Thanks for the information!
Loved the tutorial. The waterbreak 56:01 was very much needed. Great work!
This video is a godsend. Exactly what I was looking for. Keep it up man :)
Wow.... what can I say? Spending more than an hour and get the nice things I am looking for. Thanks and thank you very much. Simple but covers all. Great effort my bro....
bro this is the most cleanest jwt video ive seen even after 4 years bro , thank u sooooooooooooooooooooooooooooooo much dude
I smashed the like button so hard I cracked my screen - Thank you so much!
First, let me start by saying i appreciate the energy and effort into making these tutorials and sharing them for free that should never be taking for granted so thank you yet i was expecting it to be JWT focused since that's mainly in the title but you only start using it around 58:00 i do understand this topic involves a lot of boilerplate to demonstrate
1:12:53 --> how to automate this action of adding that "auth-key" onto the header? Like if it is a real web app, how should a request be handled?
U can intercept the request and add it
@hapi/joi Chage so at 27:00 it's "const schema = Joi.object({//properties here})" and at 29:00 it's "const validation = schema.validate(req.body);"
New version of Joi there is not Joi.validate() . You should use schema.validate(req.body) 28:46
The best tutorial on internet, really simple and well explained!!!
It would be a great FAVOR if you can do another VIDEO which help with UNIT TEST like how we can integrate UNIT testing using JEST for this login app OR any node app
For those running in to a Joi.validate issue ~28:00, Joi.validate is no longer a function and instead you turn the schema object in to a const schema = Joi.object({username: blahblah...}) and then run schema.validate(req.body) instead of Joi.validate(req.body, schema)
Hey dE.... Please extend on this topic and make one more video about implementing the frontEnd for this Auth API. Please😫🙏🙏💓
Yes..it would be great if you teach us how to design the front-end for this.
It would be awesome tho
yeps we need how can i use nuxtjs SSR
TraversyMedia has one using JWT as well.
Good job on github-readme-stats :)
great video. node and express is so much easier than any other language I've tried to learn back end on including python. thank you.
Such good video topics for beginners. Going to watch this one now.
I love how Ed is funny withouth pushing it. He just is.
The best auth tutorial ever...
Finally this video came as a savior for me. Thanks Dev Ed 💖
Also, if someone is watching in 2021, schema.validate() is the new function instead of Joi.validate()
here is the code you might stuck at->
//Register validation
const registerValidation = (data) => {
const schema = Joi.object({
name: Joi.string().min(6).required(),
email: Joi.string().min(6).required().email(),
password: Joi.string().min(6).required(),
});
return schema.validate(data);
};
Hi Dev i've a problem.. when i send the /register request from postman, the server stops at "await user.save()" (without any response).. (i think is a mongodb user problem... but i created also another account with reading and writing privileges..)
Same... if someone could help us :)
Did you solve the issue?
best tutorial ever. Highly recommended to watch to clarify your concepts. Thanks Dev Ed
Great tutorial but having an issue saving to the database. Everything else works as expected, my db connection, user model is correct when logged to console, but if I add async and await it hangs then gives an error in postman. Do I need to manually create a collection in Atlas before? Any ideas, been trying to fix this for hours and getting fed up as followed this video word for word in my code :(
try {
const savedUser = await user.save();
res.send(savedUser);
} catch (err) {
res.status(400).send(err);
}
Make sure your connection string has the correct username and password
hi did u manage to figure this out, i am facing the same problem
Try dropping the entire table from mongo and run again shell as:
>> mongo
db.dropDatabase();
exit
im facing the same problem :(
please help :(
me too help
This is easily the best video covering JWT I've ever seen. Super easy to follow and understand
Really Nice work man! It helped me a lot to understand auth with json. Thanks.
What about a frontend for this login, and if the user is valid, we redirect him to a page with the transition (using jsx, styled components, etc) from the last video.
This tut is beautiful. It chronologically tells me what all needs to be taken care of during setting up auth. I always used to get confused with the chronology.
if you end up sending the name, email, password from an actual HTML form (browser), you will need: app.use(express.urlencoded({ extended: true })) in the index.js file.
Can you show you you did this? I am trying to do this same thing but I have no idea how to implement my html file. gitrepo or contact me please g.jonathan252@gmail.com
Wow!! you explain things so seamlessly, feel great to learn things, so I hit that subscribe button, guess i will learn lot more on nodejs from this channel, love it
"Life is wonderful when things work."
Thanks Dev Ed this help me lot !!!!
If anyone facing error at 29:00 as joi.validate() is not a function just type instead schema.validate(req.body) but before this create const schema = joi.object({...../*and create here validation schema*/....})
The new version of Joi requires validation to be written like this:
const schema = Joi.object({ name: Joi.string() .min(6) .required(),
email: Joi.string() .min(6) .required() .email(),
password: Joi.string() .min(6) .required() });
const validation = schema.validate(req.body);
res.send(validation.error.details[0].message);
Yes this worked for me
im not being able to make it work when the validation is in another file, i can avoid any error returning schema.validate(data) instead of Joi.validate(data, schema), but its not actually apllying the validation. Any tip?
@@ShikaNiots maybe some issues with import/export statements of that file
@@ShikaNiots i was facing the same issue, got it to work with removing schema param from the return in the validation.js file using the updated joi documentation. e.g. "return schema.validata(data);"
I always like your videos because of how you kick them off, I'm usually serious when looking for such content and i highly appreciate you making me laugh!
Good stuffs everytime 😍 do MERN videos too 😆😆😆
I agree :D
Absolutely fucking not.
MEVN or MESN
@@iHack-ms5nr Why do you hate React?
@@kattenelvis1778 Can't stand it. The startup company I'm working in wanted me to write their microservices in React. I said I'd quit if they forced me to write React, so they changed their mind. I know use the MEVN stack on all their microservices, and the other developers on the team love me for that xd
Great tut, he really has a way to breaking down things! I like that he focuses on the 'matter' on hand, and what doesn't and can waste time (like waste time making actual forms, he has other tuts for that that) and most importantly, like his other tuts, he puts all those concepts / libraries / tools into perspective allowing you to understand how they all relate.
Thanks man :)
Can you please publish the finalized code?
If anyone is having issues with connecting to the database, you need to first create a database and the collection on the mongodb page
at 12:24 when he get the url it only appears the that needs to be changed into the user password, but in my case it also had a after the .net and there you have to put the name of the database you created, he used a database called test
Hey Dev Ed great tutorial. I would like some help implementing a logout function with the JWT
JWT is stateless, it seems cannot be logout from server side, @Dev Ed, could you please confirm..
amazing video - the only update needed that I can see is Joi changed their syntax so now you need to write it the following way:
const schema = Joi.object({
email: Joi.string().min(6).required().email(),
password: Joi.string().min(6).required(),
});
return schema.validate(data);
0:08 watching this during corona lockdown belike :3
If you don't know anything about RESTful APIs and you don't wanna waste precious time of yours then do not skip even a second of this video and you'll be just like me(who knew nothing how to code RESTful APIs) who can code RESTful APIs damn easily now💯💕
Your time and efforts are much appreciated Ed!
Please do MERN Stack. Thanks for the Content.. Helps a lot.
You did an amazing job. I get this a lot better now! One thing I wished was that you’d explain more about what a middleware was more in depth. But, I’m in a web dev elective in my CS program right now so I kinda already knew!
Needless to say, you did a killer job. You moved faster than a super slow beginning tutorial but not too fast that no one would understand.
Thank you !
Joi has changed the way of defining schema and calling functions. Checkout the documentation for further details.
I would appreciate if you can let us know how is it done for the newer version with an example please?
@@ricksondmanix3760
const schema = Joi.object({
name: Joi.string()
.min(6)
.required(),
email: Joi.string()
.min(6)
.required()
.email(),
password: Joi.string()
.min(6)
.required()
});
router.post('/register', async (req, res) => {
//VALIDATE DATA
const validation = schema.validate(req.body);
res.send(validation);
});
Its like this, just copy and paste - More info check hapi.dev/family/joi/?v=16.1.7
I know you have to heard this once in a while dev, i love you, i'm learning to get a job partly because of you !
why not making a full project based course? I'm sure to be the 1st one who buy it ~~
I will, it just takes a loong loong time to make and edit 😀
@@developedbyed i will buy it
@@developedbyed Would be very grateful if u could make something related to e-commerce/shopping cart from scratch (both the client and server) which is very in demand now. Other tutorials nowadays just suck as they give us many basic things and less real scenarios. They don't visualize the way to dive into these patterns as u do.
First of all, I love your energy. Make me more excited to learn. I plan of mastering node.js (express) to become a back end dev and secure a proper job. Wish me luck. Thank you so much.
Hey guys, @24:34 unable to get the result... Anyone please suggest me what should do?
I love the way u make Videos it's really relaxing and at the same time provides me knowledge. I have to say that there are few people i meet in my life journey of 20 who teaches so beautifully like you.Thank you for all you have done for the community
Another awesome vid. Did the rest API yesterday, and this was a great follow up. Good job!
I'm half way through this and all I can say is this is the better of the lot in terms of clear explanations and just overall goodness
VERY WELL presented! You presented jwt's and mongo access, api routes, etc. in a very easy to follow manner.
Now, I need to go back and implement this in a project as I watch and follow along again so that it sinks in to my squishy brain. :)
Dude I saw like 3 JWT tutorials before this one, but my face was like WTF! then I came here and I now have a very good understanding of it!!! thanks a lot!!!!
I know how to build an authentication system with jwt, but this is one of the best explanations i ever seen mate!
The best videos that I found in YT , thanks you bro 🙂👍🏻💯
Thanks to you, I can now easily work as a MERN stack developer. Dev Ed you are a champ
Really fun learning with you. I'm new to all this nodejs + mongo + everything else (old guy that worked on Oracle all his life) :) And you are teaching at the perfect speed!
Seen a lot of tutorials, but none match your clarity of explanation. Keep up the good work:)
Course is so great but part 46:03 joi function 'validate' is no longer supported in that fashion, use ==>
//VALIDATION
const Joi = require("joi");
const Validateschema = Joi.object({
fullname: Joi.string().min(6).required(),
email: Joi.string().min(6).required(),
password: Joi.string().min(5).required(),
});
router.post("/enroll", async (req, res) => {
const validate = Validateschema.validate(req.body);
res.send(validate);
Thanks.
Thanks!
Finally I understood how to work with JWT! Thank you so much for this awesome tutorial!!
OMG I have never ever learnt so much as I have done in this course wow So engaging, entertaining and full of useful information!!! Anyone reading highly RECOMMENDED!! Could you do tutorial where you build a basic like backend system that post stuff to like the front end :)
I love you bro ,
started learning nodejs , after your rest api tut , binging on ur tuts .
Teo years later, it is the end of July now.
And, i am just sitting home watching coding videos.
This is the best tutorial I've seen on JWT. Keep producing more content!