Awesome tutorial! To others doing it in 2023, here are fixes for a few errors I got due to updated versions of Mongoose: - One is around the Authentication section of the video: 'MongooseError: Model.findById() no longer accepts a callback'. I had success changing the code to deserializeUser at the end of passport.js to: passport.deserializeUser(async (id, done) => { done(null, await User.findById(id)) }) - Another error was the DELETE request section, in the stories.js file: 'TypeError: Story.remove is not a function'. Here I had success changing Story.remove() to Story.deleteOne()
Also after mongoose v6+ the mongoose.connect(uri, options), for options: useUnifiedTopology: true, useNewUrlParser: true, useCreateIndex: true, useFindAndModify: false there is no need to add these. basically, you can use: mongoose.connect(uri), because these methods are now used as default.
It's difficult to live in a third world country and buy udemy courses to keep up with modern technologies. But your videos on different issues and technologies are so much helpful for me and I needed a video like this so badly, Thank you so much, Brad. Love from Pakistan.
Now Udemy has become very expensive. Normal price I get for Node and React corses are 95-100 Euro (~120 dollars). And I live in Sweden and can't afford that. So everyone be sure to don't block adds on UA-cam so we can keep this UA-cam learning alive.
@@aaaaaaaaaa9837 Ohh .... I was just looking at Griders "The Complete Developers Guide to MongoDB". For me it is 99.99 Euro (~ $119). it's an insane price that I sadly can't afford.
dont u have problems with MongoStore? it told me this MongoStore.create({mongoUrl: process.env.MONGO_URI,}), ^ TypeError: Cannot read properties of undefined (reading 'create')
Honestly, it seems that we all love the videos like this. It's raw, shows that even the most seasoned get tired, burnt, and still have to google, and it encompasses the REAL process. I know that this is not advantageous for you, especially being tired, but we love the rawness. Keep em coming if you desired to! If not, then your regular tutorials work out just as well. :) Thanks Brad!
@@saoudeltelawy8971 Yes, this is using server side templates as opposed to rendering a JSON API and using a frontend framework. I may do the same app using React on the frontend at some point
@@arielcg_ I'm trying to execute this: $ npm install express --save or any dependency i cant install it it show me the below error type please help me brad !!! And I'm getting this log: > npm > ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! network request > to npm.jibo.com:8080/express failed, reason: connect ETIMEDOUT > 10.0.0.106:8080 npm ERR! network This is a problem related to network connectivity. npm ERR! network In most cases you are behind a proxy or > have bad network settings. npm ERR! network npm ERR! network If you > are behind a proxy, please make sure that the npm ERR! network 'proxy' > config is set properly. See: 'npm help config' I have no Idea what I'm doing with Node and npm because I'm new to this I have tried to look for a solution, but nothing points me in the right direction, probably because I'm asking wrong questions. i have try to excute this : Npm config set registry registry.npmjs.org/ But i cant install express or any other dependency I am student in college i use wifi does this have problem? Please guys help me out one of you pleases 🙏🙏🙏🙏🙏🙏🙏🙏
Handlebars: Access has been denied to resolve the property. I've been getting this warning. So I'm using handlebars/allow-prototype-access to pass in the data. But this seems to be vulnerable to security risks for a production level application. Anybody who's been able to solve this issue?
@@allanalexander8049 Are you using .lean() on the query? Check this page - stackoverflow.com/questions/59690923/handlebars-access-has-been-denied-to-resolve-the-property-from-because-it-is
In the new version of passport, req.logout() is now an asynchronous function, whereas previously it was synchronous. Hence you need to modify the logout route from the tutorial. The logout route was previously: router.get('/logout', (req, res, next) => { req.logout(); res.redirect('/') }) should be modified to: router.get('/logout', (req, res, next) => { req.logout((error)=>{ if (error) {return next(error)} res.redirect('/') }); })
Hello, in the stroy POST route when you define -> req.body.user = req.user.id, It keeps seding an error : BSONTypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer When I know that the id send to mongo is not an onbjectId type and that's wht it doesnt work, but how it worked for your code? Any help please ????
Hey, thanks! Going over this again and def won't work the old way. I do have a question. I understand 'async await' to be used when the function needs to wait for something. I don't see the words "async' or 'await' here. and I'm guessing maybe we wait a beat for whether or not we have an error? Am I totally out in left field? That's where you'll usually find me.
2 days ago I made the decision to change my life and become a full stack dev. Then Brad drops the mother of all node tutorials. BOOOOM. Thanks Brad, your my favorite teacher!
*If you get ERROR* ... MongoStore cannot be invoked without 'new'. Solution is to change two lines of code: *OLD* const MongoStore = require('connect-mongo')(session) *NEW* const MongoStore = require('connect-mongo') *OLD* store: new MongoStore({ mongooseConnection: mongoose.connection }) *NEW* store: MongoStore.create({ mongoUrl: process.env.MONGO_URI }) Be sure you have the name MONGO_URI in your env-file.
1.) MongoParseError: option usefindandmodify is not supported If above error occurs in your code. Just remove useFindAndModify: false this from your code. 2.) app.engine('.hbs', exphbs({defaultLayout: 'main', extname: '.hbs'})); app.set('view engine', '.hbs'); If you use above code and if TypeError: exphbs is not a function this error occurs, just use "exphbs.engine( )" instead of "exphbs( )"
do u know ho to solve this error it gaves me? store: MongoStore.create({mongoUrl: process.env.MONGO_URI,}), ^ TypeError: MongoStore.create is not a function
The logout function for Passport no longer works since version 0.6.0. You'll want to use: router.get('/logout', function(req, res, next) { req.logout(function(err) { if (err) { return next(err); } res.redirect('/'); }); });
As per an update to passport, in /routes/auth.js, in the logout helper, replace ``` req.logout(); res.redirect(); ``` with ``` req.logout(function(err) { if (err) { return next(err); } res.redirect('/'); }); ```
i'm getting a "MongooseServerSelectionError: bad auth Authentication failed." despite following all the steps, full error log here pastebin.com/R5ACrSaj in case anyone wants to help.
15:20 Mongoose 6+: useNewUrlParser, useUnifiedTopology, useFindAndModify, and useCreateIndex are no longer supported options. Mongoose 6 always behaves as if useNewUrlParser, useUnifiedTopology, and useCreateIndex are true, and useFindAndModify is false. Please remove these options from your code.
*UPDATE:* For "Logout", the new way should be: router.get('/logout', (req, res, next) => { req.logout( (err) => { if(err){return next(err)} res.redirect('/') } ) })
Does it remove session in MongoDB? In my case this method doesn't remove session and req.session.destroy() either. I'm using passport-local instead of GoogleOAuth.
If anyone is doing this currently, there have been some package changes, just copy Brad's package.json file and do `npm i` instead of installing from the terminal. Good exercise would be to do this, then update the packages and fix the changes.
The one main thing I wanted from this video is to how to maintain user login session using mongodb as the session store, and I got it at 1:09:36. Thanks Brad
Thank you so much for this Brad! I'm one of those that bought your dev to deployment course a while back and have to say that this is an absolutely incredible gift! I will definitely be updating my story books app! Thank you! Thank you! Thank you!
There are a few things missing including the comment functionality. I may do a part 2 with comments and add some new stuff as well like a local login option
const exphbs = require('express-handlebars'); app.engine('.hbs', exphbs.engine({extname: '.hbs'})); app.set('view engine', '.hbs'); This should work if anyone stuck
Very helpful tutorial, thanks! When I go to create an API key I first have to go through the OAuth consent screen which requires me to choose a User Type and gives me two options, Internal and External and then requires some config such as setting an application name. Might be worth mentioning this in the comments or description since it's not included in the video.
@@surfoyb8727 I went on to chose external and set up everything else that was required and its working all well even when I have not added any billing account. I don't know why.
I chose external as well and for now it seems to be working. But as far as I understand, once you reach 100 signed up users, the verification process is implemented.
Fantastic tutorial, took me weeks to get through (a few mins at a time here and there) but this is fantastically in depth and delivered so clearly. Thanks!
This is just so amazing, I learn a lot from all your videos. Thank you so much for all the efforts you put in to make all these videos that help your viewers so much. It's just amazing. Thank you so much Brad Traversy Sir. Thanks a lot . You are one of my favorite instructors
Thank you Brad, you are the best! At 2:00:00, instead of creating "select" Helper, I created a "ifEqual" Helper: ifEqual: function (input, value) { return input == value } These are my options in edit.hbs: Public private
I love your project based approach to your videos :) Really helps to show a full and realistic development workflow in a way that a lot of online programming courses/tutorials don't.
The part of the video 02:05:02 where Brad said, "let's actually replace the var with let..i don't like the sight of var" really got me laughing & chuckling. This ia an awesome video altogether! It helped me gain mastery of google-auth. Thanks a ton from Nigeria!
I swear to god I took the entire last week making a webapp with Node, Express, and Google Oauth with Passport. It was challenging to find resources for all of these, but I had fun. I finally pack up everything and release the project and decided to chill, and I get the notification for this video! Eventhough I just completed a project I'll surely try this out Brad! Thanks for all the effort you're putting in!
//Deploying this app on heroku remove cross-env from start script while deploying app on heroku this will help Add your app uri (domain on which you are going to host your webapp) to Google O auth ' s authorized urls by this change your url is verified to use Google O auth service it will take some time !!!
Brad you are a talented teacher and programmer. This tutorial is very complete, I think I have to watch more and more times to understand everything well. Thanks
Anyone else has the urge going on a buying spree on Udemy of all of his courses?... I already bought the Angular in-depth, waiting for a good deal to buy the NodeJS and React in-depth courses. So happy I found this channel!
I love how raw this video is. It shows the honest view into engineering and not this "pro" fake view that good engineers just coding a million miles an hour. Great video!
At 1:44:13 I wasn't getting the profile images loaded. Google was returning a 403. When I placed referrerpolicy='no-referrer' in the image element inside of index.hbs it worked.
I recently started to learn JavaScript to fill some unexpected free time (thanks COVID.....) and I have to say that you are one of the instructors I have ever found on UA-cam! You have a knack for explaining what you are doing at just the right level of detail to understand what is going on without getting bogged down. Thank you!
Can we get a celebrity boxing match from all the -grift- course sales companies. Idk if some of these comapnies are like "sister comapnies" or however one would phrase that. Pluralsight vs Udemy coursemakers celebrity boxing. Stefan Mischook could be the referee.
Just completed building this. Took me like ~6Hrs. Totally understand your handwork behind creating such an amazing tutorial. Learned a lot of things. Actually this is my first time ever implementing google sign-in. Thank you so much
At 1:09:00 you need to change MongoStorore to this: const MongoStore=require("connect-mongo") and your app.use(session) code to: app.use(session({ secret: 'keyboard cat', resave: false, saveUninitialized: false, store: MongoStore.create({ mongoUrl:process.env.MONGO_URI, mongooseConnection: mongoose.connection}),
Easier version for edit story form select: Public Private and in utils: export function select(selected, option) { return (selected == option) ? 'selected="selected"' : ''; }
Oh man, I watched this video a week ago and it completely converted me from being a full time C#/JAVA developer into a a Node.js one, ever since Node.js released it was like a mystery to me, I watched tutorials before but man you can teach. I started a new project (commissioned by an old customer of mine) using Java a month ago, then I watched this and now I'm redeveloping the whole project using Node and Express and guess what I'm enjoying it. I can't think of a reason why you don't create for Udemy, I would definitely buy some of your courses. Thanks man you just made my work so easy.
couldnt get the handlebars working as shown in the video... something must have changed since it was created. what worked for me was replacing "const exphbs = require('express-handlebars')" with "const { engine } = require('express-handlebars')" and "app.engine('.hbs', exphbs({ defaultLayout: 'main', extname: '.hbs' }))" with "app.engine('handlbars', engine({ extname: '.hbs', defaultLayout: "main" }))"... was getting an error exphbs is not a function. found the solution here: ua-cam.com/video/VSDZvQeR34M/v-deo.html
You are THE BEST INSTRUCTOR I have ever seen!!! I watched sooooo many of your UA-cam tutorials and also have completed 3 of your Udemy courses!!! I just love your workflow!!!! Please please make complete tutorial on MERN stack app on Ecommerce webapp or a social media webapp!!!!🙏🙏🙏🙏🙏
Dude you're incredible. I got really discouraged starting with backend stuff. I feel like I'm 10000times more understanding of whats going on now. Thank you!
Thanks so much Traversy!!! You're the goat, I learned absolutely so much from this, and it being outdated helped me learn even more and get practice debugging!
In regards to the Oauth consent page issue, choose external. Then, you only need to type in the name of the application and scroll down and save. In not filling out all of the information, it does cap the number of users that can log in to the app to 100, but it should be fine for the sake of completing the tutorial.
@2:02:11: "Told you this wouldn't be polished" Sir, we don't care if it is polished or not. We love any content that you put out because you are an ocean of knowledge for us devs. Thank you.
Check out for 1:12:10 where the {{name}} never shows up. -When i made the 'name: req.user.firstName' request, firstName property was never returned, so I tried to console.log the req.user and it did return me the "Id" stored in mongo. -So after a chat with a GPT friend we discover a way to make it work and here it's the code modified from the routes>index.js file `router.get('/dashboard', ensureAuth, async (req, res) => { try { const user = await User.findById(req.user.id).select('firstName'); res.render('dashboard', { name: user.firstName, }); } catch (error) { console.error(error); res.render('error'); } });` be sure to add this to the top of the file `const User = require('..User/models/User')`. Hope it helps! Great video Brad :)
You are really an awesome teacher. I have learned with you ( React & Node ) and I did my first project with your course. Now, I'm thankful with this tutorial. Thanks so much.
Took me around 5 hours to go through this in one sitting, except I used EJS instead of handlebars, but really learned a lot. The Google OAuth part is invaluable. Thanks Brad
So the only way I could get the stripTags and truncate to work is to swap them around. Instead of {{stripTags (truncate body 150)}} I had to use {{truncate(stripTags body) 150}} I know it's something I did just wanted to mention it incase anyone's having the same issue. I'm glad I can watch your videos though helps me with my job.
@@rizkimasjahri3592 in video 25:24 after i change my .send to .render, before that when i run using .send localhost:3000 showing the "Login" but when applying .render wont show anything. appreciate bro im stuck on this 2 days now.
Man, can't believe it. I just started an app where I want to use Node, Express, MongoDB and thought about to use next to an user authetification Google OAuth. You can imagine how I got excided when I saw this video. ))) Thank you
Thank you,sir. This vedio is blessing for me. Finally I have done this projrct with you and learn so many things about a organize node project. God bless you.
Finished 7/10/23 , god this was really tiring!!! wow!! lots of information to take in, definitely gotta go back and understanding everything through. As always, thanks for the amazing content Brad!
Man, you're awesome. I'm now writing on php Laravel and trying to find something useful about Node JS and it is just it. Everything I want to know about Node at the beginning is here and in other your videos about that topic. Thank you!
Awesome. You’ve become my goto in inspiration for all things code. I’m still working my way through your Udemy React Front to Back but this has a lot of the functionality my project could use once I have the structure sorted. Many thanks from the UK.
Thanks, Brad. I have been watching you since my early days as a student in software development. You have inspired me a lot. It's true that I'm mostly into .Net development but I always find good takeaways from your all tutorials.
I have been looking for this for sometime now, this is awesome and perfect timing! I needed this right now. Brad delivers so much value, that's why I purchase all his courses.
Thank you for long videos like this. They maybe not get views, but they ar good for competent people to dive head first. I was your dec 2021 vlog, one thing your could do is break have 60 mins for node/express, 60 mins react, and 60 mins for mongo, password, security, OAuth...
Awesome tutorial!
To others doing it in 2023, here are fixes for a few errors I got due to updated versions of Mongoose:
- One is around the Authentication section of the video: 'MongooseError: Model.findById() no longer accepts a callback'. I had success changing the code to deserializeUser at the end of passport.js to:
passport.deserializeUser(async (id, done) => {
done(null, await User.findById(id))
})
- Another error was the DELETE request section, in the stories.js file: 'TypeError: Story.remove is not a function'. Here I had success changing Story.remove() to Story.deleteOne()
OMG! Thank you so much! You're a GODSEND. I hope your pillow is always cold at night.
THANK YOU!!
Also after mongoose v6+ the mongoose.connect(uri, options), for options:
useUnifiedTopology: true,
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false
there is no need to add these.
basically, you can use: mongoose.connect(uri), because these methods are now used as default.
Thank you!
router.get('/logout', (req, res, next) => {
req.logout((err) => {
if (err) {
return next(err);
}
res.redirect('/');
});
});
for errror
req#logout requires a callback function
The timestamp feature is really user friendly. Good one from youtube.
I know right? I just found out about it. I will be using it quite a bit from now on
@@TraversyMedia Awesome!
@@TraversyMedia I am getting error 'TokenError: client_secret is missing'.
agreed
@@TraversyMedia how to deploy this project
It's difficult to live in a third world country and buy udemy courses to keep up with modern technologies. But your videos on different issues and technologies are so much helpful for me and I needed a video like this so badly, Thank you so much, Brad. Love from Pakistan.
Now Udemy has become very expensive. Normal price I get for Node and React corses are 95-100 Euro (~120 dollars). And I live in Sweden and can't afford that. So everyone be sure to don't block adds on UA-cam so we can keep this UA-cam learning alive.
@@jellycoding WOW here in Brazil it's just 4 euros on sale
@@aaaaaaaaaa9837 Ohh .... I was just looking at Griders "The Complete Developers Guide to MongoDB". For me it is 99.99 Euro (~ $119). it's an insane price that I sadly can't afford.
in india we get for less that 7 $'s approx
@@siddhantraj5323 Really? Why is it so expensive in Sweden? I checked right now and Traversy course MERN is 149.99 Euros (~179 dollar). That's crazy.
const { engine } = require("express-handlebars");
app.engine(
"hbs",
engine({
extname: "hbs",
defaultLayout: false,
layoutsDir: "views/layouts/",
})
);
app.set("view engine", "hbs");
app.set("views", "./views");
This should work if anyone stuck
Hey Ajay! Are you a fresher and open to opportunities in web development currently? Have you created any projects in JavaScript frameworks?
Thanks for the help but mine is still not working, I am getting this Error: No default engine was specified and no extension was provided.
Thanks!!
Thank you!
dont u have problems with MongoStore? it told me this
MongoStore.create({mongoUrl: process.env.MONGO_URI,}),
^
TypeError: Cannot read properties of undefined (reading 'create')
Honestly, it seems that we all love the videos like this. It's raw, shows that even the most seasoned get tired, burnt, and still have to google, and it encompasses the REAL process. I know that this is not advantageous for you, especially being tired, but we love the rawness. Keep em coming if you desired to! If not, then your regular tutorials work out just as well. :) Thanks Brad!
That introductory sound. You're the BEST Brad.
Ngl I get chubbed up every time I hear it
It drives me nuts. Always skip.
@@sonarsphere Sorry :( I tried to make as short as possible. I also stopped sponsors for now so you guys don't have to watch a 30 sec ad
This is so great .. so this is a topic for anyone “Front end “ and want to know about Backend as newbie of BAckend using “Node.Js” ... am i right???
@@saoudeltelawy8971 Yes, this is using server side templates as opposed to rendering a JSON API and using a frontend framework. I may do the same app using React on the frontend at some point
Intro - 00:00
Database Setup - 3:41
Install Dependencies - 6:10
Initial Express Setup - 10:26
Connect Database - 14:00
Morgan Logger - 17:27
Template Engine & Layouts - 18:22
Index Routes & Views - 21:44
Materialize & Font Awesome - 25:54
Set Static Folder - 26:55
Login Layout - 29:13
Login Page Template - 31:55
Start Google Login - 33:57
Passport Intro - 36:46
Passport Config & Sessions - 39:00
User Model - 42:49
Passport Google Strategy - 45:41
Auth Routes - 49:50
Save Google Profile Data - 55:06
Logout - 59:54
Navigation - 1:01:11
Auth Middleware - 1:03:22
Store Sessions In Database - 1:08:36
Story Model - 1:12:27
Dashboard Stories - 1:14:44
Add Story - 1:21:57
Format Date Handlebar Helper - 1:33:35
Public Stories - 1:36:40
Truncate & StripTags Helpers - 1:44:10
Edit Icon Helper - 1:47:04
Edit Story - 1:54:21
Method Override For PUT Requests - 2:02:30
Method Override For DELETE Requests - 2:10:56
Single Story Page - 2:18:46
User Stories - 2:24:36
@@arielcg_ Wow I did not even know about this. Some UA-camr I am haha
@@arielcg_ I'm trying to execute this:
$ npm install express --save or any dependency i cant install it it show me the below error type please help me brad !!!
And I'm getting this log:
> npm
> ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! network request
> to npm.jibo.com:8080/express failed, reason: connect ETIMEDOUT
> 10.0.0.106:8080 npm ERR! network This is a problem related to network connectivity. npm ERR! network In most cases you are behind a proxy or
> have bad network settings. npm ERR! network npm ERR! network If you
> are behind a proxy, please make sure that the npm ERR! network 'proxy'
> config is set properly. See: 'npm help config'
I have no Idea what I'm doing with Node and npm because I'm new to this
I have tried to look for a solution, but nothing points me in the right direction, probably because I'm asking wrong questions.
i have try to excute this :
Npm config set registry registry.npmjs.org/
But i cant install express or any other dependency
I am student in college i use wifi does this have problem?
Please guys help me out one of you pleases 🙏🙏🙏🙏🙏🙏🙏🙏
Ariel, is this tutorial for beginners? Someone who knows some JS only.
Handlebars: Access has been denied to resolve the property. I've been getting this warning. So I'm using handlebars/allow-prototype-access to pass in the data. But this seems to be vulnerable to security risks for a production level application. Anybody who's been able to solve this issue?
@@allanalexander8049 Are you using .lean() on the query? Check this page - stackoverflow.com/questions/59690923/handlebars-access-has-been-denied-to-resolve-the-property-from-because-it-is
Brad is the type of person that, when delivery something, delivery much more than expect. Thank you for always help us with amazing contents.
In the new version of passport, req.logout() is now an asynchronous function, whereas previously it was synchronous. Hence you need to modify the logout route from the tutorial.
The logout route was previously:
router.get('/logout', (req, res, next) => {
req.logout();
res.redirect('/')
})
should be modified to:
router.get('/logout', (req, res, next) => {
req.logout((error)=>{
if (error) {return next(error)}
res.redirect('/')
});
})
What is the use of the accessToken and refreshToken in the callback? Since you only need the profile to set up the session.
The code:
router.get('/logout', (req, res, next) => {
req.logout((error)=>{
if (error) {return next(error)}
res.redirect('/')
});
})
should be
router.get('/logout', (req, res, next) => {
req.logout((error)=>{
if (error) {return next(error)}
});
res.redirect('/')
})
thanks, this helped me out
Hello, in the stroy POST route when you define -> req.body.user = req.user.id, It keeps seding an error : BSONTypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer
When I know that the id send to mongo is not an onbjectId type and that's wht it doesnt work, but how it worked for your code?
Any help please ????
Hey, thanks! Going over this again and def won't work the old way. I do have a question. I understand 'async await' to be used when the function needs to wait for something. I don't see the words "async' or 'await' here. and I'm guessing maybe we wait a beat for whether or not we have an error? Am I totally out in left field? That's where you'll usually find me.
2 days ago I made the decision to change my life and become a full stack dev. Then Brad drops the mother of all node tutorials. BOOOOM. Thanks Brad, your my favorite teacher!
I love how you leave the mistakes in the video, debugging is such a big part of the process.
did u notice any?
These are not mistakes, but changes in some packages over time )) The older tutorial you use, the more problems you encounter.
@@arijitroy8390 there are and there should be in real life programming. e.g., at @ the date should be story.createdAt not date now.
@@volodymyr7214 and after two years there are even more, but it is the process of making everything running really makes you progressing isn't it?
@@seedme For sure! I like challenges )
*If you get ERROR* ... MongoStore cannot be invoked without 'new'.
Solution is to change two lines of code:
*OLD* const MongoStore = require('connect-mongo')(session)
*NEW* const MongoStore = require('connect-mongo')
*OLD* store: new MongoStore({ mongooseConnection: mongoose.connection })
*NEW* store: MongoStore.create({ mongoUrl: process.env.MONGO_URI })
Be sure you have the name MONGO_URI in your env-file.
thanks
thanks!
Thank you!
cheers mate!
Thanks dear!!
I was looking for passport and google Oauth yesterday 🙃. Now I have a tutorial from by fav instructor ❣️.
1.) MongoParseError: option usefindandmodify is not supported
If above error occurs in your code. Just remove useFindAndModify: false this from your code.
2.) app.engine('.hbs', exphbs({defaultLayout: 'main', extname: '.hbs'}));
app.set('view engine', '.hbs');
If you use above code and if TypeError: exphbs is not a function this error occurs, just use "exphbs.engine( )" instead of "exphbs( )"
Thank you :)
Cheers buddy.
do u know ho to solve this error it gaves me?
store: MongoStore.create({mongoUrl: process.env.MONGO_URI,}),
^
TypeError: MongoStore.create is not a function
Thanks mate!
My whole semester in 2:30 hours
Thanks Brad
The logout function for Passport no longer works since version 0.6.0. You'll want to use:
router.get('/logout', function(req, res, next) {
req.logout(function(err) {
if (err) {
return next(err);
}
res.redirect('/');
});
});
As per an update to passport, in /routes/auth.js, in the logout helper, replace
```
req.logout();
res.redirect();
```
with
```
req.logout(function(err) {
if (err) { return next(err); }
res.redirect('/');
});
```
Just now, I spoke with my friend about learning nodejs.
And here they are.
Man! This is Awesome 🤘🏻
Love your content ❤️
YEAH!!!!! more long form content from Brad is what we need, GO BRAD!!!!
i'm getting a "MongooseServerSelectionError: bad auth Authentication failed." despite following all the steps, full error log here pastebin.com/R5ACrSaj in case anyone wants to help.
@@evenzero Maybe it's due to that authentication link. Try MongoDB with a different account.
@@evenzero remove < > these angled brackets surrounding password and dbname in the connection URL
@@Techjd bro how to deploy this...im getting error in heroku while deploy
It is immpossible to believe, Brad made over 2 hours course for youtube. awesome
I needed this so badly. 😭
bro how to deploy this...im getting error in heroku while deploy
15:20 Mongoose 6+: useNewUrlParser, useUnifiedTopology, useFindAndModify, and useCreateIndex are no longer supported options. Mongoose 6 always behaves as if useNewUrlParser, useUnifiedTopology, and useCreateIndex are true, and useFindAndModify is false. Please remove these options from your code.
thanks, fixed my bug
how much i have to remove , it will be great if you can share the code
then instead of these options , what i"ll add?
*UPDATE:* For "Logout", the new way should be:
router.get('/logout', (req, res, next) => {
req.logout( (err) => {
if(err){return next(err)}
res.redirect('/')
} )
})
Does it remove session in MongoDB? In my case this method doesn't remove session and req.session.destroy() either. I'm using passport-local instead of GoogleOAuth.
Thanks this helped! What was the update that made this necessary ?
Confirmed that this fixed the "req#logout requires a callback function" error message that I was getting. Thanks Namlas!
Also fixed it for me. Thanks!
If anyone is doing this currently, there have been some package changes, just copy Brad's package.json file and do `npm i` instead of installing from the terminal. Good exercise would be to do this, then update the packages and fix the changes.
Brad, to escape text formatting when pasting, use CTRL+SHIFT+V ;)
The one main thing I wanted from this video is to how to maintain user login session using mongodb as the session store, and I got it at 1:09:36.
Thanks Brad
Thank you so much for this Brad! I'm one of those that bought your dev to deployment course a while back and have to say that this is an absolutely incredible gift! I will definitely be updating my story books app!
Thank you! Thank you! Thank you!
There are a few things missing including the comment functionality. I may do a part 2 with comments and add some new stuff as well like a local login option
const exphbs = require('express-handlebars');
app.engine('.hbs', exphbs.engine({extname: '.hbs'}));
app.set('view engine', '.hbs');
This should work if anyone stuck
Thank you so much!
@@celesterhoades4845 100devs, let's go
Thank you🎉
Thanks for taking the time to explain all of the steps. Lots of videos, but not all of them take the time to thoroughly explain everything.
Very helpful tutorial, thanks!
When I go to create an API key I first have to go through the OAuth consent screen which requires me to choose a User Type and gives me two options, Internal and External and then requires some config such as setting an application name. Might be worth mentioning this in the comments or description since it's not included in the video.
Heyy Ewan is that going to charge for API services on usage? I m stuck.
has anyone got anymore information on this?
@@surfoyb8727 I just chose external, as the internal option was disabled, then set an application name and everything worked fine
@@surfoyb8727 I went on to chose external and set up everything else that was required and its working all well even when I have not added any billing account. I don't know why.
I chose external as well and for now it seems to be working. But as far as I understand, once you reach 100 signed up users, the verification process is implemented.
Fantastic tutorial, took me weeks to get through (a few mins at a time here and there) but this is fantastically in depth and delivered so clearly. Thanks!
Nice one, almost the Equivalent to an Udemy Course.
bro how to deploy this...im getting error in heroku while deploy
@@kazcode1937 How can you expect someone to answer you if you don't put the type of error you are getting?
One of the best tutorial videos I’ve ever watched. I feel like I learned more in this video than I have in the past year of front end development
This is just so amazing, I learn a lot from all your videos. Thank you so much for all the efforts you put in to make all these videos that help your viewers so much. It's just amazing. Thank you so much Brad Traversy Sir. Thanks a lot . You are one of my favorite instructors
I really appreciate this "unpolished" tutorial because it gives a realistic look into the process of developing an application. Thank you for sharing!
Hello Brad! I am your student from Ghana. I just want you to know that, you're the best. I picked up your JavaScript course on udemy and I loved it.
Thank you Brad. This is literally exactly what I was waiting for. I will forever be a patreon!
It's crazy that I was searching for Traversy MongoDB videos and he literally made a new one today :)
A great video for those of us trying to learn backend development. Thanks for making such great tutorials Brad!
Thank you Brad, you are the best!
At 2:00:00, instead of creating "select" Helper, I created a "ifEqual" Helper:
ifEqual: function (input, value) {
return input == value
}
These are my options in edit.hbs:
Public
private
I love your project based approach to your videos :) Really helps to show a full and realistic development workflow in a way that a lot of online programming courses/tutorials don't.
The part of the video 02:05:02 where Brad said, "let's actually replace the var with let..i don't like the sight of var" really got me laughing & chuckling.
This ia an awesome video altogether! It helped me gain mastery of google-auth. Thanks a ton from Nigeria!
long time no see
missed you so much
busy with two daughters these days
Congrats! Daughters are the best :)
This shows why you are the best,
Crystal clear explanation which lacks in other youtubers.You are the best!
I swear to god I took the entire last week making a webapp with Node, Express, and Google Oauth with Passport. It was challenging to find resources for all of these, but I had fun. I finally pack up everything and release the project and decided to chill, and I get the notification for this video!
Eventhough I just completed a project I'll surely try this out Brad! Thanks for all the effort you're putting in!
//Deploying this app on heroku
remove cross-env from start script while deploying app on heroku
this will help
Add your app uri (domain on which you are going to host your webapp) to Google O auth ' s authorized urls by this change your url is verified to use Google O auth service
it will take some time !!!
Brad you are a talented teacher and programmer. This tutorial is very complete, I think I have to watch more and more times to understand everything well. Thanks
Actual Tutorial : 2:28:42
Me: 3 days . HAHAHA
Me: 4 days. 2 days of fixing typos, smh.
Same it took me 3 days 😄
@@tarunsankhla2328 bro aik error a rha hai 25:54 pr views folders sa files match nhi ho rhi
Links pr visit kro tokich show nhi hota
Anyone else has the urge going on a buying spree on Udemy of all of his courses?...
I already bought the Angular in-depth, waiting for a good deal to buy the NodeJS and React in-depth courses.
So happy I found this channel!
I love how raw this video is. It shows the honest view into engineering and not this "pro" fake view that good engineers just coding a million miles an hour. Great video!
the "clienID" at 47:30 was driving me nuts. Also it's comforting to know that I'm not the only one who does stuff like this.
Great content! This would also be cool to use MySQL as an alternative to MongoDB.
that debugging at 1:32:00 was epic, a really important skill.
At 1:44:13 I wasn't getting the profile images loaded. Google was returning a 403. When I placed referrerpolicy='no-referrer' in the image element inside of index.hbs it worked.
Thanks a lot Brad, this is by far the most complex application that I have made. Please make more tutorials like this.
For People facing error of connect-mongo @1:10:21 install connect-mongo version 3.2.0
npm uninstall connect-mongo
npm install connect-mongo@3.2.0
You save me man, thanks
tried almost everything and this one was the one and only ty bud.
Thank you so very much for the solution. I have been searching around trying to figure out a solution. And nothing worked. So I appreciate your help
I recently started to learn JavaScript to fill some unexpected free time (thanks COVID.....) and I have to say that you are one of the instructors I have ever found on UA-cam! You have a knack for explaining what you are doing at just the right level of detail to understand what is going on without getting bogged down. Thank you!
Brad's 2 hour course = other's 5-6 hour's
Yes that's true. I feel the same.
i am pretty sure it took him longer than that to record the video
true, unlike maximilliam's super long courses, brad's short courses completely outperform !!!
Can we get a celebrity boxing match from all the -grift- course sales companies.
Idk if some of these comapnies are like "sister comapnies" or however one would phrase that.
Pluralsight vs Udemy coursemakers celebrity boxing.
Stefan Mischook could be the referee.
Thank you so much! I have finally finish this tutorial
stuck at edit icon helper 1:53:03 , throw me an error : " Cannot read property '_id' of undefined ", while click on public stories. Help me out..
Same have you found the solution yet??
i am also stuck there...did any one find the solution
Just completed building this. Took me like ~6Hrs. Totally understand your handwork behind creating such an amazing tutorial. Learned a lot of things. Actually this is my first time ever implementing google sign-in.
Thank you so much
Is it deploy you in any platform like heroku
At 1:09:00 you need to change MongoStorore to this:
const MongoStore=require("connect-mongo")
and your app.use(session) code to:
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: false,
store: MongoStore.create({
mongoUrl:process.env.MONGO_URI,
mongooseConnection: mongoose.connection}),
}))
Thanks for this quick fix.🤗
Thanks mate❤
Easier version for edit story form select:
Public
Private
and in utils:
export function select(selected, option) {
return (selected == option) ? 'selected="selected"' : '';
}
this is nice
Thanks, this worked great for me!
Oh man, I watched this video a week ago and it completely converted me from being a full time C#/JAVA developer into a a Node.js one, ever since Node.js released it was like a mystery to me, I watched tutorials before but man you can teach. I started a new project (commissioned by an old customer of mine) using Java a month ago, then I watched this and now I'm redeveloping the whole project using Node and Express and guess what I'm enjoying it. I can't think of a reason why you don't create for Udemy, I would definitely buy some of your courses. Thanks man you just made my work so easy.
He actually has many udemy courses
@@humankind5627 I'll definitely check it out.
@@humankind5627 Just bought "Electron From Scratch: Build Desktop Apps With JavaScript" by Brad.
couldnt get the handlebars working as shown in the video... something must have changed since it was created. what worked for me was replacing "const exphbs = require('express-handlebars')" with "const { engine } = require('express-handlebars')" and "app.engine('.hbs', exphbs({ defaultLayout: 'main', extname: '.hbs' }))" with "app.engine('handlbars', engine({ extname: '.hbs', defaultLayout: "main" }))"... was getting an error exphbs is not a function. found the solution here: ua-cam.com/video/VSDZvQeR34M/v-deo.html
Thanks 🙏👍
You are THE BEST INSTRUCTOR I have ever seen!!! I watched sooooo many of your UA-cam tutorials and also have completed 3 of your Udemy courses!!! I just love your workflow!!!!
Please please make complete tutorial on MERN stack app on Ecommerce webapp or a social media webapp!!!!🙏🙏🙏🙏🙏
Dude you're incredible. I got really discouraged starting with backend stuff. I feel like I'm 10000times more understanding of whats going on now. Thank you!
Thanks so much Traversy!!! You're the goat, I learned absolutely so much from this, and it being outdated helped me learn even more and get practice debugging!
In regards to the Oauth consent page issue, choose external. Then, you only need to type in the name of the application and scroll down and save. In not filling out all of the information, it does cap the number of users that can log in to the app to 100, but it should be fine for the sake of completing the tutorial.
Just about to start a project using google oauth and you uploaded this. Thanks man. You are saviour
i literally just downloaded a basic express + typescript starter code to get working on my next API project. Good timing.
@2:02:11: "Told you this wouldn't be polished" Sir, we don't care if it is polished or not. We love any content that you put out because you are an ocean of knowledge for us devs. Thank you.
Check out for 1:12:10 where the {{name}} never shows up.
-When i made the 'name: req.user.firstName' request, firstName property was never returned, so I tried to console.log the req.user and it did return me the "Id" stored in mongo.
-So after a chat with a GPT friend we discover a way to make it work and here it's the code modified from the routes>index.js file
`router.get('/dashboard', ensureAuth, async (req, res) => {
try {
const user = await User.findById(req.user.id).select('firstName');
res.render('dashboard', {
name: user.firstName,
});
} catch (error) {
console.error(error);
res.render('error');
}
});`
be sure to add this to the top of the file `const User = require('..User/models/User')`.
Hope it helps! Great video Brad :)
Helped me! Only my file structure was different: `const User = require('../models/User')`
That was the easy part though!
Awesome !! thanks you saved my precious time
You are really an awesome teacher. I have learned with you ( React & Node ) and I did my first project with your course. Now, I'm thankful with this tutorial. Thanks so much.
Took me around 5 hours to go through this in one sitting, except I used EJS instead of handlebars, but really learned a lot. The Google OAuth part is invaluable. Thanks Brad
happen to have a git repo I could peek at for EJS set up? I'm not understanding why mine isn't rendering properly
Hey, can you give the repo link / source code if possible
Brad, You have finally shown me why I need to learn node! Oh my... this tutorial is like a whole course mehn....
It is probably one of the most impressive tutorails that I have ever did, thank you! I hope that you do more tuts like that about node js!
So the only way I could get the stripTags and truncate to work is to swap them around.
Instead of {{stripTags (truncate body 150)}} I had to use {{truncate(stripTags body) 150}} I know it's something I did just wanted to mention it incase anyone's having the same issue. I'm glad I can watch your videos though helps me with my job.
Thank you so much 😊, I was also having issue with it. I was searching for comment related to it. It worked. Thanks again...
This may be the best advanced web dev tutorial on youtube. Top work Brad
thank you brad! took 3 days (6 hours per day) for me to follow this awesome tutorial.
hi sir i see that you finish the video mine was stuck bcos index.js is not rendering to html. help pls thnks appreciated
@@my.code.studio where section that you get stuck?
@@rizkimasjahri3592 in video 25:24 after i change my .send to .render, before that when i run using .send localhost:3000 showing the "Login" but when applying .render wont show anything. appreciate bro im stuck on this 2 days now.
Man, can't believe it. I just started an app where I want to use Node, Express, MongoDB and thought about to use next to an user authetification Google OAuth. You can imagine how I got excided when I saw this video. ))) Thank you
Thank you Brad for making all great videos to help junior developers improve
Thank you,sir. This vedio is blessing for me. Finally I have done this projrct with you and learn so many things about a organize node project. God bless you.
Finished 7/10/23 , god this was really tiring!!! wow!! lots of information to take in, definitely gotta go back and understanding everything through. As always, thanks for the amazing content Brad!
Man, you're awesome. I'm now writing on php Laravel and trying to find something useful about Node JS and it is just it. Everything I want to know about Node at the beginning is here and in other your videos about that topic. Thank you!
Bro thanks for this comprehensive tutorial , this guy should be given a Nobel prize
It's great having these projects for reference when I need to remember how to do something. Also I learn a lot in the process. thanks a ton Brad.
Took me a whole day, but got through it.
Brad - This tutorial is EPIC!!!
You are a legend!
This video is amazing and 100 percent made me understand express and mongodb so much better. You are the man!
Awesome. You’ve become my goto in inspiration for all things code. I’m still working my way through your Udemy React Front to Back but this has a lot of the functionality my project could use once I have the structure sorted. Many thanks from the UK.
Thanks, Brad. I have been watching you since my early days as a student in software development. You have inspired me a lot. It's true that I'm mostly into .Net development but I always find good takeaways from your all tutorials.
Hi, brad, your teaching methodology it's so simple and cool it's so difficult not to understand.MUNGU AKUBARIKI.
who are these people who dislike such a great tutorial video? they don't deserve to be here.
I have been looking for this for sometime now, this is awesome and perfect timing! I needed this right now. Brad delivers so much value, that's why I purchase all his courses.
Hey thank's man. I just learned basics of node and wasn't feeling much confident but this video helped me a lot, thanks man. 🙏🙏
Thank you for all the knowledge you impart onto all of us. After this video, nothing can stop me now!
Thank you for long videos like this. They maybe not get views, but they ar good for competent people to dive head first.
I was your dec 2021 vlog, one thing your could do is break have 60 mins for node/express, 60 mins react, and 60 mins for mongo, password, security, OAuth...
Can't wait to wake up and start learning. You're the man, Brad.
Brad, you are more than human. Thank you for sharing your wealth of knowledge with us.
TRAVERSY MEDIA is the best web Dev explaining channel and Instructor I have ever seen...!!