Skip to main content

Posts

Showing posts from July, 2020

Passport Package for Authentication in NodeJS

I watched a video and learnt about the passport  package to handle the authentication and save the user data in MongoDB from Google. Passport is the middleware for NodeJS. It can be used to authenticate using a username and password, Facebook, Twitter, Google and more. It is simple to use and flexible. Steps to use passport package for google authentication: - install passport npm i passport passport-google-oauth20 --save I used the below code to handle the authentication.  1. This file has Google strategy to fetch the user's profile from user's Google profile and saving it in my MongoDB. passport.js const GoogleStrategy = require ( 'passport-google-oauth20' ); const User = require ( '../models/User' ); module . exports = function ( passport ) { passport . use ( new GoogleStrategy ({ clientID : process . env . GOOGLE_CLIENT_ID , clientSecret : process . env . GOOGLE_CLIENT_SECRET , callbackURL : '/auth/google/callbac...

Firebase: Introduction to Cloud Firestore

I am learning about the cloud firestore. I learnt from Firebase docs and videos. mostly videos and you can also watch the video and come back here to take these notes as reminder about the video. What is NoSQL Database? NoSql databases are usually schema-less, it means there are not any kind of restriction to store the data in the database. So, NoSql database is not going to store the all of data in table like structure. There are different ways to store the data. It can be:- Plain key value pair Nested tree structure  JSON object This type of approach of storing the data may look messy but lots of developer like working with a schema-less database. In NoSQL database, we can easily add or change the fields without breaking anything in design. For the every record in NoSQL database, fields can be different, for eg: one record has {firstName, lastName, age} and for the next record we stored as {firstName, middleName, lastName, age, city}. The drawback here is th...

"NodeJS Basics" Theory That You Should Know

To know better about NodeJS, you should know Javascript. So I start with Javascript Javascript is in top 3 language. JavaScript is developed on December 4, 1995. It was a client-side scripting language. So it was used only in browsers. Javascript uses  Javascript engine that is used by browsers to convert code into machine code. We have multiple JavaScript engines just like we have different browsers like Firefox, Chrome, internet explorer, edge etc. First JavaScript engine was SpiderMonkey developed by Netscape Communication by the creator of JavaScript Brendan Eich and it was developed in 10 days. Different browsers are using a different type of Javascript Engine:- Internet Explorer is using Chakra Firefox is using Spidermonkey Chrome is using V8 Microsoft Edge is rebuild using a chromium-based browser and now it is using V8 engine. Most Famous engine is now V8 Javascript engine because it is faster and can be used for mobile development...