Build A Node.js API Authentication With JWT Tutorial

  Рет қаралды 733,056

developedbyed

developedbyed

Күн бұрын

Check out my courses and become more creative!
developedbyed.com/
In this episode we are going to create a node.js api that is going to handle Authentication for us in any application we want to use it in.
We are going to cover an authentication method using jwt. We will use mongodb as our database, mongoose to create models and to connect to our express server, bcryptjs to hash passwords and jwt to check for private routes.
❤Become a patreon for exclusive videos and more!
/ dev_ed
📕 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
Microphones I Use
Audio-Technica AT2020 - geni.us/Re78 (Amazon)
Deity V-Mic D3 Pro - geni.us/y0HjQbz (Amazon)
BEHRINGER Audio Interface - geni.us/AcbCpd9 (Amazon)
Camera Gear
Fujifilm X-T3 - geni.us/7IM1 (Amazon)
Fujinon XF18-55mmF2.8-4 - geni.us/sztaN (Amazon)
PC Specs
Kingston SQ500S37/480G 480GB - geni.us/s7HWm (Amazon)
Gigabyte GeForce RTX 2070 - geni.us/uRw71gN (Amazon)
AMD Ryzen 7 2700X - geni.us/NaBSC (Amazon)
Corsair Vengeance LPX 16GB - geni.us/JDqK1KK (Amazon)
ASRock B450M PRO4 - geni.us/YAtI (Amazon)
DeepCool ATX Mid Tower - geni.us/U8xJY (Amazon)
Dell Ultrasharp U2718Q 27-Inch 4K - geni.us/kXHE (Amazon)
Dell Ultra Sharp LED-Lit Monitor 25 2k - geni.us/bilekX (Amazon)
Logitech G305 - geni.us/PIjyn (Amazon)
Logitech MX Keys Advanced - geni.us/YBsCVX0 (Amazon)
DISCLAIMERS:
I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.
🛴 Follow me on:
Twitter: / deved94
Instagram: / developedbyed
Github: github.com/DevEdwin
🎵 Music:
Outro:
LAKEY INSPIRED - Me 2 (Feat. Julian Avila)
Music By: / lakeyinspired
Intro:
Dj Quads
Track Name: "Every Morning"
Music By: Dj Quads @ / aka-dj-quads
Creative Commons - Attribution-ShareAlike 3.0 Unported- CC BY-SA 3.0
creativecommons.org/licenses/b...
#nodejs #authentication #api

Пікірлер: 1 600
@wandilenxumalo735
@wandilenxumalo735 5 жыл бұрын
I had to rewind that magic trick about 10 times. It made my day, thank you :D
@movinmove
@movinmove 4 жыл бұрын
playspeed 0.25 :D
@developerspoint6059
@developerspoint6059 4 жыл бұрын
Yeah it helps 😊
@manibharathy1994
@manibharathy1994 4 жыл бұрын
I did the same, with 0.25 speed
@gihanrangana6248
@gihanrangana6248 4 жыл бұрын
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);
@robinnatter8884
@robinnatter8884 4 жыл бұрын
@@gihanrangana6248 What do that
@developedbyed
@developedbyed 5 жыл бұрын
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!
@Lionellord
@Lionellord 5 жыл бұрын
Thx Ed
@ridl27
@ridl27 5 жыл бұрын
very useful content bro! but can you share the code with us please ?
@AnhPham-pf4cj
@AnhPham-pf4cj 5 жыл бұрын
appreciate super like
@zimbolazimboola27
@zimbolazimboola27 5 жыл бұрын
very usefuly but can you do a tutorial for mysql for us please ??? thanks dear
@Wael100
@Wael100 5 жыл бұрын
Hi, Dev I would like to find a direct link for the code in the description if you don't mind :)
@ibosnfs1997
@ibosnfs1997 5 жыл бұрын
People still spending money for bad tutorials, while you can find the best one on KZfaq. Great tutorial! 👌🏻
@iercan1234
@iercan1234 5 жыл бұрын
True.
@thangtea18bec
@thangtea18bec 5 жыл бұрын
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
@Vietnamcamping89
@Vietnamcamping89 4 жыл бұрын
Yep, this true
@janklager7085
@janklager7085 4 жыл бұрын
totally true
@blufrog9546
@blufrog9546 4 жыл бұрын
agree, u never get bored while following his videos
@depthsofmindshorts
@depthsofmindshorts 4 жыл бұрын
"Life is wonderful when things work." - DevEd, 2019
@codingdaily4094
@codingdaily4094 4 жыл бұрын
Literally, I will make it make my Whatsapp status and Insta bio
@srinadhj2638
@srinadhj2638 3 жыл бұрын
wtf
@asgaraliyev8740
@asgaraliyev8740 3 жыл бұрын
@@codingdaily4094 😂😂 I Love DevEd
@biswamohandwari780
@biswamohandwari780 3 жыл бұрын
Wise genius words
@giorgigazashvili2555
@giorgigazashvili2555 11 ай бұрын
i was also drinking water when he said that DDdd
@MrVaffanci
@MrVaffanci 4 жыл бұрын
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);"
@TehBaconStrip
@TehBaconStrip 4 жыл бұрын
and setup the schema as: const schema = Joi.object({...});
@oyoyoyoyoyoy9479
@oyoyoyoyoyoy9479 4 жыл бұрын
I need to look at comments first next time)))
@ericbourne3116
@ericbourne3116 4 жыл бұрын
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.
@AlifMunim
@AlifMunim 4 жыл бұрын
a true hero, thank you
@codefumble
@codefumble 4 жыл бұрын
you're a Godsend
@AaronJack
@AaronJack 5 жыл бұрын
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!
@liorocker1
@liorocker1 5 жыл бұрын
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 :)
@bssushmitha6534
@bssushmitha6534 4 жыл бұрын
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.
@jonathannadeau8679
@jonathannadeau8679 3 жыл бұрын
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!
@JohnDoe-dz5wu
@JohnDoe-dz5wu 5 жыл бұрын
Idk how randomly i found your channel but I'm glad i did... :)
@frankli2425
@frankli2425 5 жыл бұрын
This channel is criminally under subbed. Keep up the good work, love your content!
@daboos8
@daboos8 4 жыл бұрын
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.
@javierramirez798
@javierramirez798 4 жыл бұрын
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!
@joooosh9432
@joooosh9432 5 жыл бұрын
Literally one of my fav Tubers at the moment. Can't wait to see your success 😏
@eswilhite
@eswilhite 5 жыл бұрын
I rarely comment on videos, but I'm making an exception for this one. This is an incredible intro to JWT and a solid boilerplate for jumping off applications. Good work man
@ankitsanghi
@ankitsanghi 4 жыл бұрын
This is easily the best video covering JWT I've ever seen. Super easy to follow and understand
@danielmarx1056
@danielmarx1056 3 жыл бұрын
Another awesome vid. Did the rest API yesterday, and this was a great follow up. Good job!
@everbliss7955
@everbliss7955 5 жыл бұрын
Hahahaha! That magic trick got me pumped up for the rest of the tutorial! Thanks, @Dev Ed. You are unique in an amazing way.
@zainabshah4207
@zainabshah4207 3 жыл бұрын
trueee
@Sonuyadav-ie5fb
@Sonuyadav-ie5fb 3 жыл бұрын
whenever I watch his videos he always put smile on my face. He is one of the best teacher for programming available on youtube!
@jesusredondo513
@jesusredondo513 3 жыл бұрын
I wish all tuts over Internet were this deep and condensed. This was pure gold. Thanks
@SelfDevTV
@SelfDevTV 5 жыл бұрын
This video is a godsend. Exactly what I was looking for. Keep it up man :)
@justinp.1543
@justinp.1543 4 жыл бұрын
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.
@fedus22
@fedus22 4 жыл бұрын
Something very good to know
@paritoshbatish9984
@paritoshbatish9984 4 жыл бұрын
@@fedus22 I agree
@somebodyyouusedtoknow8600
@somebodyyouusedtoknow8600 4 жыл бұрын
thank you random programmer!
@tomascalvo8
@tomascalvo8 3 жыл бұрын
good idea
@nikhilmine
@nikhilmine 2 жыл бұрын
Then we should probably change the name to 'Last updated date' instead of Date
@starX7995
@starX7995 7 ай бұрын
bro this is the most cleanest jwt video ive seen even after 4 years bro , thank u sooooooooooooooooooooooooooooooo much dude
@gabrielartiola3721
@gabrielartiola3721 4 жыл бұрын
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
@aris.konstantinidis
@aris.konstantinidis 4 жыл бұрын
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!
@sharonsegal1255
@sharonsegal1255 4 жыл бұрын
I smashed the like button so hard I cracked my screen - Thank you so much!
@frixaco
@frixaco 4 жыл бұрын
Finally I understood how to work with JWT! Thank you so much for this awesome tutorial!!
@tambolaking5383
@tambolaking5383 4 жыл бұрын
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.
@pratikwadekar4981
@pratikwadekar4981 4 жыл бұрын
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.
@LeaDClan
@LeaDClan 5 жыл бұрын
Such good video topics for beginners. Going to watch this one now.
@Isthiyaquekambathagothi
@Isthiyaquekambathagothi 2 жыл бұрын
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
@markkaranja11
@markkaranja11 2 жыл бұрын
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!
@zacharymeyer991
@zacharymeyer991 4 жыл бұрын
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 :)
@Saspian
@Saspian 4 жыл бұрын
thanks for help
@ultimathei
@ultimathei 4 жыл бұрын
thanks Zach!
@ujjwalbiswas8400
@ujjwalbiswas8400 4 жыл бұрын
Thank you for saving me from nightmare
@deepakseervi9496
@deepakseervi9496 4 жыл бұрын
You saved my day dude.
@souviknath7796
@souviknath7796 3 жыл бұрын
Thanks bro😄
@algife
@algife 2 жыл бұрын
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!
@AbdulMoizAsif
@AbdulMoizAsif 3 жыл бұрын
best tutorial ever. Highly recommended to watch to clarify your concepts. Thanks Dev Ed
@oscarekstrand3453
@oscarekstrand3453 3 жыл бұрын
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.
@jordanski5421
@jordanski5421 3 жыл бұрын
I quit college nevermind uni
@christossotirlis2247
@christossotirlis2247 3 жыл бұрын
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
@sina-qh8wm
@sina-qh8wm 4 жыл бұрын
The best auth tutorial ever...
@alannguyen4441
@alannguyen4441 4 жыл бұрын
Hi Ed Thank you so much for this video. Straight to the point and easy to follow. I watch it one time, and went back did the exercise along. All in all it was great.
@prashantingwl
@prashantingwl 3 жыл бұрын
I love you bro , started learning nodejs , after your rest api tut , binging on ur tuts .
@ManjunathManja1227
@ManjunathManja1227 4 жыл бұрын
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.
@biigsmokee
@biigsmokee 3 жыл бұрын
@DevEd, if you put 0:00:00 Start in the description you will get hotspots on the video
@Ayoub_Himself
@Ayoub_Himself 3 жыл бұрын
For anyone struggling with the string length validation, you should use minLength / maxLength for strings rather than min / max which is for numbers
@shinan1329
@shinan1329 2 жыл бұрын
TYSM, so helpful
@secioreanuionelstefanita8687
@secioreanuionelstefanita8687 3 жыл бұрын
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 ! :))
@mehdiajouad8441
@mehdiajouad8441 4 жыл бұрын
Finally a tutorial that teach you concrete things, i used it for my app, thank you a lot
@jakubkoj1
@jakubkoj1 5 жыл бұрын
Next part maybe create a front-end to this?
@Manel15basquet
@Manel15basquet 4 жыл бұрын
Good Idea
@aryagoswami4152
@aryagoswami4152 4 жыл бұрын
YESSSSS.
@sunnyparmar9692
@sunnyparmar9692 4 жыл бұрын
hell yeah
@gobinathshanthakumar1169
@gobinathshanthakumar1169 4 жыл бұрын
@@sunnyparmar9692 yes please we need the front end to this maby with user / admin section
@dormj2
@dormj2 3 жыл бұрын
Absolutely necessary, please do it Ed!
@shubhamingale110
@shubhamingale110 4 жыл бұрын
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...
@elihergiorgana3559
@elihergiorgana3559 4 жыл бұрын
thank you :)
@syedhuzaifaali5322
@syedhuzaifaali5322 4 жыл бұрын
helped a lot thank you :)
@ujjwalbiswas8400
@ujjwalbiswas8400 4 жыл бұрын
Hey buddy, can you help me with this? "message": "\"name\" failed custom validation because Cannot read property 'presence' of undefined",
@vic-pm3rm
@vic-pm3rm 4 жыл бұрын
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.
@vic-pm3rm
@vic-pm3rm 4 жыл бұрын
and what about at 36:43? im just not an expert at node.js
@this_akashjain
@this_akashjain 4 жыл бұрын
Was looking for a NodeJs start and I think my search has ended up here. Thanks for the tut :)
@tannerbarcelos6880
@tannerbarcelos6880 4 жыл бұрын
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 !
@inamandev4389
@inamandev4389 5 жыл бұрын
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
@murillomfs
@murillomfs 5 жыл бұрын
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.
@shikhatripathi6731
@shikhatripathi6731 2 жыл бұрын
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 .
@deanjames6997
@deanjames6997 4 жыл бұрын
Wow, I learned so many things with this tutorial. Thank you Ed !
@tobyboulton8340
@tobyboulton8340 3 жыл бұрын
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
@ventifan1018 3 жыл бұрын
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); // } });
@RicardoDanyalgilJunior
@RicardoDanyalgilJunior 3 жыл бұрын
@@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() });
@junior2441
@junior2441 Жыл бұрын
@@RicardoDanyalgilJunior Thanks man!!
@mhdyousuf3392
@mhdyousuf3392 5 жыл бұрын
Please do MERN Stack. Thanks for the Content.. Helps a lot.
@pratiksaria5830
@pratiksaria5830 3 жыл бұрын
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
@nedwize
@nedwize 4 жыл бұрын
This is the best tutorial I've seen on JWT. Keep producing more content!
@GGdevelopment
@GGdevelopment 4 жыл бұрын
Can you do a second part to this? Like how to add the front end part? (like a login page, sign in, etc)...
@gobinathshanthakumar1169
@gobinathshanthakumar1169 4 жыл бұрын
yes please
@daniilthegunner843
@daniilthegunner843 3 жыл бұрын
Hey, did you find anywhere tutorial with front part?
@dhruvjain9029
@dhruvjain9029 3 жыл бұрын
Guys check out his frontend course you might find something there
@_robyn_
@_robyn_ 4 жыл бұрын
0:08 watching this during corona lockdown belike :3
@okanyldrmop
@okanyldrmop 3 жыл бұрын
One of the most excellent tutorials that I have ever seen, thank you!
@janklager7085
@janklager7085 4 жыл бұрын
Hey Ed, Thank you for your super tutorials. I'm always excited to see them. Tank you
@anuraghazra4772
@anuraghazra4772 5 жыл бұрын
Hey dE.... Please extend on this topic and make one more video about implementing the frontEnd for this Auth API. Please😫🙏🙏💓
@deepneon5414
@deepneon5414 5 жыл бұрын
Yes..it would be great if you teach us how to design the front-end for this.
@jormanfernandez8052
@jormanfernandez8052 5 жыл бұрын
It would be awesome tho
@BodrumDrone
@BodrumDrone 4 жыл бұрын
yeps we need how can i use nuxtjs SSR
@michrisoft
@michrisoft 4 жыл бұрын
TraversyMedia has one using JWT as well.
@ShikharSharma1398
@ShikharSharma1398 4 жыл бұрын
Good job on github-readme-stats :)
@georgekotsiopoulos6241
@georgekotsiopoulos6241 3 жыл бұрын
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.
@pemifo260
@pemifo260 2 жыл бұрын
Thanks for the information!
@HiImKyle
@HiImKyle 4 жыл бұрын
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
@muktaryusuf6699
@muktaryusuf6699 3 жыл бұрын
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
@ashutoshgupta450
@ashutoshgupta450 4 жыл бұрын
"Life is wonderful when things work."
@bibhushankarki9194
@bibhushankarki9194 5 жыл бұрын
Good stuffs everytime 😍 do MERN videos too 😆😆😆
@JohannyLS
@JohannyLS 5 жыл бұрын
I agree :D
@iHack-ms5nr
@iHack-ms5nr 4 жыл бұрын
Absolutely fucking not.
@iHack-ms5nr
@iHack-ms5nr 4 жыл бұрын
MEVN or MESN
@kattenelvis1778
@kattenelvis1778 4 жыл бұрын
@@iHack-ms5nr Why do you hate React?
@iHack-ms5nr
@iHack-ms5nr 4 жыл бұрын
@@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
@jazilzaim
@jazilzaim 4 жыл бұрын
Thanks for the good content and for educating us about JWT! You are definitely an amazing content creator in the tech dev space!
@mikealejandro3938
@mikealejandro3938 3 жыл бұрын
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 !
@skilled-person
@skilled-person 5 жыл бұрын
As of npm 5.0.0, installed modules are added as a dependency by default, so the --save option is no longer needed
@developedbyed
@developedbyed 5 жыл бұрын
Correct!
@skilled-person
@skilled-person 5 жыл бұрын
@@developedbyed thanks for the tutorial you covered pretty much everything related to node :)
@mucahitaslancan3282
@mucahitaslancan3282 2 жыл бұрын
New version of Joi there is not Joi.validate() . You should use schema.validate(req.body) 28:46
@brycepieroway4040
@brycepieroway4040 4 жыл бұрын
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. :)
@cristiancr7954
@cristiancr7954 2 жыл бұрын
The best tutorial on internet, really simple and well explained!!!
@vnrbhat
@vnrbhat 4 жыл бұрын
Joi has changed the way of defining schema and calling functions. Checkout the documentation for further details.
@ricksondmanix3760
@ricksondmanix3760 4 жыл бұрын
I would appreciate if you can let us know how is it done for the newer version with an example please?
@joaoolival4511
@joaoolival4511 4 жыл бұрын
@@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
@gabrielzanarelli724
@gabrielzanarelli724 5 жыл бұрын
Great tutorial. I have one question. What is your Color Theme for VSC ?
5 жыл бұрын
+1 Color Theme and Icon Theme please :)
@pjguitar15
@pjguitar15 3 жыл бұрын
I really like how you give us knowledge and good laugh at the same time
@qianbang_
@qianbang_ 3 жыл бұрын
This is all you need to learn rest API as a whole. Thanks for the video
@4541047
@4541047 5 жыл бұрын
Thanks man :) Can you please publish the finalized code?
@prosperarineitwe9147
@prosperarineitwe9147 4 жыл бұрын
Hey Dev Ed great tutorial. I would like some help implementing a logout function with the JWT
@8kelvin
@8kelvin 3 жыл бұрын
JWT is stateless, it seems cannot be logout from server side, @Dev Ed, could you please confirm..
@vstrato
@vstrato 4 жыл бұрын
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!
@silenceofthelans
@silenceofthelans 4 жыл бұрын
You're gold Ed. Your work is wonderful and you really are a great teacher. Congratulations!
@calvinbarajas5144
@calvinbarajas5144 3 жыл бұрын
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.
@ign_alpha
@ign_alpha 3 жыл бұрын
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
@fabriziosalvade3661
@fabriziosalvade3661 Жыл бұрын
Fantastic! I always learn a lot with yours videos. You are a great teacher!
@terrencelouis7075
@terrencelouis7075 3 жыл бұрын
amazing. so easy to follow without being too drawn out. thank you so much.
@adiletdaniyarov5737
@adiletdaniyarov5737 3 жыл бұрын
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?
@josielsantos8283
@josielsantos8283 3 жыл бұрын
U can intercept the request and add it
@BlackBastard815
@BlackBastard815 4 жыл бұрын
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..)
@elisarenda9003
@elisarenda9003 4 жыл бұрын
Same... if someone could help us :)
@aamirjamal6833
@aamirjamal6833 4 жыл бұрын
Did you solve the issue?
@robertdowney336
@robertdowney336 4 жыл бұрын
Your tutorials are awesome and really easy to understood as a beginner. Greetings from France !
@thukukanyoro5863
@thukukanyoro5863 2 жыл бұрын
Thank you for this video. It gave me a good introduction to rest api in general.
@kevinskeldon1451
@kevinskeldon1451 5 жыл бұрын
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); }
@aaronbrill616
@aaronbrill616 5 жыл бұрын
Make sure your connection string has the correct username and password
@JohnGreen-qc5xb
@JohnGreen-qc5xb 5 жыл бұрын
hi did u manage to figure this out, i am facing the same problem
@Sakonii_
@Sakonii_ 4 жыл бұрын
Try dropping the entire table from mongo and run again shell as: >> mongo db.dropDatabase(); exit
@potatoondaflo
@potatoondaflo 4 жыл бұрын
im facing the same problem :( please help :(
@thatrafi5691
@thatrafi5691 4 жыл бұрын
me too help
@johnconnor9787
@johnconnor9787 3 жыл бұрын
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);
@keduslejiyared8701
@keduslejiyared8701 3 жыл бұрын
Yes this worked for me
@ShikaNiots
@ShikaNiots 3 жыл бұрын
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?
@johnconnor9787
@johnconnor9787 3 жыл бұрын
@@ShikaNiots maybe some issues with import/export statements of that file
@JaredAkers
@JaredAkers 3 жыл бұрын
@@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);"
@rickynino6763
@rickynino6763 2 жыл бұрын
Learned a lot from this tutorial Ed. Many thanks.
@lucabaxter4002
@lucabaxter4002 4 жыл бұрын
I know how to build an authentication system with jwt, but this is one of the best explanations i ever seen mate!
@NhanNguyen-yf9cv
@NhanNguyen-yf9cv 5 жыл бұрын
why not making a full project based course? I'm sure to be the 1st one who buy it ~~
@developedbyed
@developedbyed 5 жыл бұрын
I will, it just takes a loong loong time to make and edit 😀
@perc-ai
@perc-ai 5 жыл бұрын
@@developedbyed i will buy it
@NhanNguyen-yf9cv
@NhanNguyen-yf9cv 5 жыл бұрын
@@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.
@narasis
@narasis 4 жыл бұрын
Thanks Ed, this video was perfekt for me that is totally new in the programming world. Make more node tutorials, ur doing it perfect I learn superfast! // Thanks from sweden
@Anstroy95
@Anstroy95 4 жыл бұрын
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!!!!
@drlucky5474
@drlucky5474 3 жыл бұрын
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....
@AvielCo_
@AvielCo_ 3 жыл бұрын
You are amazing, best tutor on KZfaq, so fun to learn from you.
@ujjwaljain9780
@ujjwaljain9780 3 жыл бұрын
life is wonderful when things work.......Thanks for covering each topic so nicely
@chadiusmaximus9350
@chadiusmaximus9350 3 жыл бұрын
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.
@sumukhakb2701
@sumukhakb2701 3 жыл бұрын
Oh man, this is an awesome tutorial. you explained every concept very well.
@prashantjani2963
@prashantjani2963 2 жыл бұрын
This was the best jwt auth tutorial i found on youtube thank you very much..
What Is JWT and Why Should You Use JWT
14:53
Web Dev Simplified
Рет қаралды 1,1 МЛН
Little girl's dream of a giant teddy bear is about to come true #shorts
00:32
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 10 МЛН
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 114 МЛН
Build A Restful Api With Node.js Express & MongoDB | Rest Api Tutorial
53:55
Node.js API Authentication With JWT
23:01
Traversy Media
Рет қаралды 555 М.
JWT Authentication in Go (Gin/Gorm)
35:26
Coding with Robby
Рет қаралды 67 М.
Think Fast, Talk Smart: Communication Techniques
58:20
Stanford Graduate School of Business
Рет қаралды 39 МЛН
The Story of Next.js
12:13
uidotdev
Рет қаралды 559 М.
How To Manage User Roles In Node.js
22:45
Web Dev Simplified
Рет қаралды 306 М.
What is JWT? JSON Web Tokens Explained (Java Brains)
14:53
Java Brains
Рет қаралды 1 МЛН
How to build a REST API with Node js & Express
58:40
Programming with Mosh
Рет қаралды 1,7 МЛН
📱магазин техники в 2014 vs 2024
0:41
djetics
Рет қаралды 520 М.
Лучший браузер!
0:27
Honey Montana
Рет қаралды 1 МЛН
Kumanda İle Bilgisayarı Yönetmek #shorts
0:29
Osman Kabadayı
Рет қаралды 2,4 МЛН
Xiaomi SU-7 Max 2024 - Самый быстрый мобильник
32:11
Клубный сервис
Рет қаралды 540 М.
Better Than Smart Phones☠️🤯 | #trollface
0:11
Not Sanu Moments
Рет қаралды 16 МЛН