Skip to main content

Posts

Showing posts from April, 2020

JSON Web Token Introduction

JSON Web Token Introduction JSON Web Token (JWT) is an open standard 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 . When should you use JSON Web Tokens? Authorization : This is the most comm on sce nario for using JWT. Once the user is logged in, each subsequent request will include the JWT, allowing the user to access routes, services, and resources that are permitted with that token. Single Sign On is a feature that widely uses JWT nowadays, because of its small overhead and its ability to be easily used across different domains. Information Exchange : JSON Web Tokens are a good way of securely transmitting information between parties. Because JWTs can be signed—for example, using public/private key pairs—you can

Building a RESTful CRUD API with Node.js, Express, MongoDB

Used Libraries Express Validator Mongoose _____________Just 3 Steps________________ Step 1 Initialize the project npm init -y npm install --save-dev nodemon npm install express mongoose npm install validator Now go to the package.json and modifiy the scripts property like this. Then create folder call utils and create a file call db.js inside it. Here is my project structure. If  you haven't any idea to get MongoDB Connection String please refer first part from  here. Follow these set of code for RESTful API crud operations.    Step 2     db.js const mongoose = require('mongoose'); const validator = require('validator'); const url = 'MongoDB Connection String'; mongoose.connect(url,{useUnifiedTopology:true,useNewUrlParser:true}); const Schema = mongoose.Schema; const userSchema = new Schema({     name : {         type : String,         require : true,         trim : true     },     age : {         type

Node.js RESTful API Introduction

What is REST architecture? REST stands for REpresentational State Transfer. REST is web standards based architecture and uses HTTP Protocol. It revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP standard methods. A REST Server simply provides access to resources and REST client accesses and modifies the resources using HTTP protocol. Here each resource is identified by URIs/ global IDs. REST uses various representation to represent a resource like text, JSON, XML but JSON is the most popular one. HTTP methods GET  − This is used to provide a read only access to a resource. PUT  − This is used to create a new resource. DELETE  − This is used to remove a resource. POST  − This is used to update a existing resource or create a new resource. RESTful Web Services A web service is a collection of open protocols and standards used for exchanging data between applications or systems. Software

An Introduction to Mongoose, Express for MongoDB With NodeJS

This is about how to connect with MongoDB from NodeJS. Used Libraries Express  Mongoose Steps... 1. npm init -y 2. npm install --save-dev nodemon              coppy this inside package.json                 "scripts":{                   "start": "node app",                  "dev": "nodemon app"           } 3. npm i express mongoose db.js (Inside the utils folder) const mongoose = require('mongoose'); const validator = require('validator'); const url = 'MongoDB Connection String'; mongoose.connect(url,{useUnifiedTopology:true,useNewUrlParser:true}) .then(res => console.log(res)) .catch(err => console.log(err)); app.js const express = require('express'); require('./utils/db'); const app = express(); app.listen(3000);  For execute npm run dev

Simply NodeJS Introduction

NodeJS Is Opensource cross platform run time environment for developing server side web application. It runs on google's V8 JavaScript engine. NodeJS Is Not Another web framework. It is a module of JavaScript. For beginners. Multi thread. What is unique about NodeJS Server side module. Servers are normally thread based. But NodeJS is event based. NodeJS programs are executed by V8  JavaScript Engine the same used by Google Chrome browser.