In my last post, I spent some hours to create a stub to skip passport.authenticate method for REST API testing. So, I decided to write a separate post on the same. Before we get started, let’s take a look on how auth middleware is implemented:
Month: December 2017
Node.js: REST API Testing using Mocha, Sinon and Chai
In my recent post, I covered how to implement token based authentication using Passport, JWT and bcrypt. Let’s extend this post and look into testing REST APIs or server side methods in Node.js using Mocha, Chai and Sinon.
Mocha: It is a test runner to execute our tests.
keywords in code = Describe, It, before, after…etc
Chai: It is an assertion library and allows to write code like writing regular english.
keywords in code = should, assert..etc.
Sinon: It provides test spies (fake functions to track executions), stubs (replace functions with our fake implementation) and mocks (predefined fake method with behaviour).
JavaScript: Null vs Undefined vs Undeclared
For a beginner, it is painful to understand two distinct things null & undefined in JavaScript and use them properly. I noticed many people consider and treat undeclared variable as undefined which is wrong perception. In this article, we will go through null, undefined, empty, NaN and undeclared variables and see how to handle them in different conditions.
Token Based Authentication with Node.js, Express, Mongoose and Passport
This tutorial explains how to implement REST API and Token based authentication in Node.js, Express, Mongoose environment. We are going to use JWT (JSON Web Token) + bcrypt (password hashing algo)+ Passport (authentication middleware to integrate different login strategies) combination. So jsonwebtoken, bcrypt-nodejs and passport-jwt javascript libraries will be used. It is assumed you are familiar with Node.js, MongoDB and ES6 basics.
Deploying a MEAN App to Azure App Services via GitHub
Do you want to setup your MEAN stack (MongoDB, Express, AngularJS and Node.js) application on Azure App Services with Continuous Integration and Delivery? Here are step by step videos to deploy a MEAN application to Azure Web Apps via GitHub and store the app’s data inside Cosmos DB (a drop-in replacement for MongoDB).
How to Load Disqus Comments on Click
On searching Google, I got many articles on this but didn’t find any way to do if official Disqus comment system WordPress plugin is used. So, decided to write on it. This post explains how to setup Disqus on your website to load on-demand (on click on any button or link) and not automatically. It is assumed you’ve registered your website with Disqus before get started.