Today we are gonna see how to authenticate users by creating a simple user auth system.

we are gonna use NodeJS,Express,Mongodb,JWT.

Before starting let’s understand What is JWT?

JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA or ECDSA.

What is JSON Web Token structure?

JSON Web Tokens consist of three parts separated by dots (.), which are:


For creating a node.js project, we need to install node.js from node.org.

Let’s create our project directory, then we run the npm init command

mkdir mynodeapp
cd mynodeapp
npm init

explanation-

1. mkdir — to make a directory.

2.cd mynodeapp — move to project directory.

3.Using npm init to Initialize a Project.

following are the explanation

  • The project’s name,
  • The project’s initial version,
  • The project’s description,
  • The project’s entry point (meaning the project’s main file),
  • The project’s test command (to trigger testing with something like Standard)
  • The project’s git repository (where the project source can be found)
  • The project’s keywords…


Today, we are gonna discuss how much javascript one should know before starting Node.js.

There is no specific info to know the minimum requirement of javascript for Node.js

Let’s understand why we need to know javascript before starting with node.js.

According to nodejs.org,- “Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”

Node.js is often described as a combination of C++ and JavaScript. The C++ part consists of bindings running…


According to nodejs.org,- “Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”

Today, We will try to figure out what non-blocking I/O model.

“I/O” refers primarily to interaction with the system’s disk and network supported by libuv.

What is non-blocking I/O?

Any process which doesn’t block execution of the next line of code. called non-blocking I/O.

let's take an example — Treat event-cycle as a waiter at a restaurant.

Suppose…


Hi, Muggles

Today we are going to learn how to parse XML files into JSON using Node.js and express.

we need to install module using npm install — save xml-js

here we are using a small block of code to convert XML to JSON.

var convert = require(“xml-js”);

var xml = require(“fs”).readFileSync(path);

var xmlData = convert.xml2json(xml, {

compact: true,

spaces: 4

});

console.log(“converted json data “)

code explanation -:

At first, we are requiring xml-js module

then we are reading XML files using the fs.readFileSync method.

now we are using xml2json() function which is provided by xml-js API.

finally storing data in XML…

Siddharth

Software Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store