Тёмный

Build A Node.js API Authentication With JWT Tutorial 

developedbyed
Подписаться 933 тыс.
Просмотров 733 тыс.
50% 1

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

Наука

Опубликовано:

 

14 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 1,6 тыс.   
@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 4 года назад
Hi, Dev I would like to find a direct link for the code in the description if you don't mind :)
@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
@depthsofmindshorts
@depthsofmindshorts 4 года назад
"Life is wonderful when things work." - DevEd, 2019
@codingdaily4094
@codingdaily4094 3 года назад
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
@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.
@ibosnfs1997
@ibosnfs1997 5 лет назад
People still spending money for bad tutorials, while you can find the best one on RU-vid. 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
@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!
@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!
@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.
@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 :)
@JohnDoe-dz5wu
@JohnDoe-dz5wu 5 лет назад
Idk how randomly i found your channel but I'm glad i did... :)
@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!
@ankitsanghi
@ankitsanghi 4 года назад
This is easily the best video covering JWT I've ever seen. Super easy to follow and understand
@joooosh9432
@joooosh9432 5 лет назад
Literally one of my fav Tubers at the moment. Can't wait to see your success 😏
@frankli2425
@frankli2425 5 лет назад
This channel is criminally under subbed. Keep up the good work, love your content!
@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
@danielmarx1056
@danielmarx1056 2 года назад
Another awesome vid. Did the rest API yesterday, and this was a great follow up. Good job!
@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
@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
@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!
@SelfDevTV
@SelfDevTV 5 лет назад
This video is a godsend. Exactly what I was looking for. Keep it up man :)
@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
@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
@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.
@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!
@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.
@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
@sharonsegal1255
@sharonsegal1255 4 года назад
I smashed the like button so hard I cracked my screen - Thank you so much!
@LeaDClan
@LeaDClan 5 лет назад
Such good video topics for beginners. Going to watch this one now.
@jesusredondo513
@jesusredondo513 3 года назад
I wish all tuts over Internet were this deep and condensed. This was pure gold. Thanks
@frixaco
@frixaco 4 года назад
Finally I understood how to work with JWT! Thank you so much for this awesome tutorial!!
@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😄
@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
@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!
@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.
@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!
@sina-qh8wm
@sina-qh8wm 4 года назад
The best auth tutorial ever...
@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 .
@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
@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
@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 !
@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
@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!
@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
@janklager7085
@janklager7085 4 года назад
Hey Ed, Thank you for your super tutorials. I'm always excited to see them. Tank you
@nedwize
@nedwize 4 года назад
This is the best tutorial I've seen on JWT. Keep producing more content!
@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
@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 Год назад
Thanks for the information!
@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
@cristiancr7954
@cristiancr7954 2 года назад
The best tutorial on internet, really simple and well explained!!!
@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.
@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 3 года назад
Good job on github-readme-stats :)
@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!
@okanyldrmop
@okanyldrmop 3 года назад
One of the most excellent tutorials that I have ever seen, thank you!
@mhdyousuf3392
@mhdyousuf3392 5 лет назад
Please do MERN Stack. Thanks for the Content.. Helps a lot.
@ashutoshgupta450
@ashutoshgupta450 4 года назад
"Life is wonderful when things work."
@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
@AbdulMoizAsif
@AbdulMoizAsif 2 года назад
best tutorial ever. Highly recommended to watch to clarify your concepts. Thanks Dev Ed
@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
@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 :)
@deanjames6997
@deanjames6997 4 года назад
Wow, I learned so many things with this tutorial. Thank you Ed !
@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 !
@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
@mehdiajouad8441
@mehdiajouad8441 4 года назад
Finally a tutorial that teach you concrete things, i used it for my app, thank you a lot
@fabriziosalvade3661
@fabriziosalvade3661 Год назад
Fantastic! I always learn a lot with yours videos. You are a great teacher!
@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!!
@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..
@valerymbele4451
@valerymbele4451 3 года назад
By far the best tuto on that topic. Thanks a lot.
@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 ! :))
@mucahitaslancan3282
@mucahitaslancan3282 2 года назад
New version of Joi there is not Joi.validate() . You should use schema.validate(req.body) 28:46
@gabrielzanarelli724
@gabrielzanarelli724 5 лет назад
Great tutorial. I have one question. What is your Color Theme for VSC ?
5 лет назад
+1 Color Theme and Icon Theme please :)
@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!
@brycepieroway4040
@brycepieroway4040 3 года назад
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. :)
@4541047
@4541047 5 лет назад
Thanks man :) Can you please publish the finalized code?
@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
@qianbang_
@qianbang_ 3 года назад
This is all you need to learn rest API as a whole. Thanks for the video
@hidayetelitok9392
@hidayetelitok9392 3 года назад
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
@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
@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
@silenceofthelans
@silenceofthelans 4 года назад
You're gold Ed. Your work is wonderful and you really are a great teacher. Congratulations!
@rickynino6763
@rickynino6763 2 года назад
Learned a lot from this tutorial Ed. Many thanks.
@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?
@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
@AvielCo_
@AvielCo_ 3 года назад
You are amazing, best tutor on RU-vid, so fun to learn from you.
@benaliyasser9735
@benaliyasser9735 2 года назад
i appreciate every second you spend on this video.. THANKS
@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);"
@revantkulkarni8734
@revantkulkarni8734 3 года назад
Great one! Learnt a lot thanks Dev Ed!
@sudershansingh2839
@sudershansingh2839 2 года назад
lovely tutorial covering all the essentials!!
@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.
@crateer
@crateer 2 года назад
What an excellent Tutorial! This helped me build my own API with authentication with ease :)
@cobain8512
@cobain8512 Год назад
best lesson i had ever in my life. you are the best after ania, love u ed
@prashantjani2963
@prashantjani2963 2 года назад
This was the best jwt auth tutorial i found on youtube thank you very much..
@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.
@alokikpathak3526
@alokikpathak3526 4 года назад
It helped me a lot! Thanks for creating great stuffs and sharing it. Love and well wishes from India.
@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....
@hamzasabri5610
@hamzasabri5610 3 года назад
Man thank u thank u thank u thank u thank u thank u a looooooooooot You see I was really confused about node and did not get much from the docs and I was upset but seeing jow easy it is and what you are doing made me feel better you made my day bru
@dezsoab
@dezsoab 2 года назад
This was very useful. Thank you Ed! 🔥
Далее
What Is JWT and Why Should You Use JWT
14:53
Просмотров 1,1 млн
[RU] Winline EPIC Standoff 2 Major | Playoffs
4:38:55
Просмотров 172 тыс.
Node.js API Authentication With JWT
23:01
Просмотров 555 тыс.
How To Manage User Roles In Node.js
22:45
Просмотров 305 тыс.
JWT Authentication Tutorial - Node.js
27:36
Просмотров 1 млн
CAN LEVY BE STOPPED?
18:00
Просмотров 197 тыс.
What are Cookies in NodeJS?
30:35
Просмотров 48 тыс.
How to build a REST API with Node js & Express
58:40
Просмотров 1,7 млн
КРУТОЙ ТЕЛЕФОН
0:16
Просмотров 5 млн
Треш ПК за 420 000 рублей
0:59
Просмотров 221 тыс.