Enzo Learns: Part 11, Refactoring bcrypt and getting my ass whooped by Async

Lorenzo Dante
2 min readJan 13, 2018

--

Oww shiet. Photo by Ashim D’Silva on Unsplash

Refactoring nodejs-bcrypt -> bcrypt

Today I updated my NPM to the latest version and that is a mistake. I was told in this dev.to thread that I should uninstall my nodejs-bcrypt package and install just bcrypt. And so did as advised. Because of being an up-to-date monster I also updated my NPM mindlessly.

Here’s when I found out that bcrypt doesn’t work on unstable releases of NPM, thus, it ended not working on my machine. Right now, I’m uninstalling node.js as I type this. And afterwards, I will reinstall the more stable version. Talk about hassle! 😅 (my fault anyways)

OK so, I completely refactored the old nodejs-bcrypt into bcrypt. Great! What’s next?

Well, I thought everything was smooth sailing. I refactored my synchronous hash functions into async but that’s where things got pretty messed up.

Enter Async

I researched for hours and it turns out I’m so noob at javascript — I mean, I still got a lot to learn.

I encountered function hoisting along the way and also Callbacks, Promises, Async/Await, and GOSH. This is a complicated concept to wrap my head around. I get the idea, but the syntax is a little tricky. And all these ES6 ES5 ESWHATTHEFU stuffs are all super confusing to me!

I’ll be reading this blog for more details, but I cannot wrap my head around it right now. I’m too sleepy and intimidated. Hopefully, when I finish that blog, I will be a better man. (I don’t wanna get stucked in callback hell)

Damn, I didn’t expect hashing then storing a password would be so hard… of course I could just use hashSync but… *that’s cheating*.

I won’t give up on this!

Funny, I’m supposed to be doing some Unit testing today with Mocha, Chai, and Mockgoose but I guess I’m going to leave that to another blog post. 😂

If you are reading this, wait, why are you reading this? Just kidding. Thanks for reading until the end! Pretty unproductive day… Not too much lines of code written. Hopefully, I can overcome this next time. Hopefully! 🤞

See y’all on the my next posts!

--

--

Lorenzo Dante

Reese’s peanut butter cup-fueled coding monster who dwells in the web. Also devours books, video games, anime, and manga. I write about everything!