Passionate, Self-taught Full Stack MERN Web Developer that loves designing and building modern websites, applications, and APIs.

Part 1: Implementing A Backend Service

Let’s build a ToDo MERN app using GraphQL and Node.js, In this part, we will implement a backend service.

Image for post
Image for post

Introduction

In this article, we will create a backend service with GraphQL i.e Apollo Server and MongoDB database.

We will be using the MongoDB database so make sure you install it locally or you can use free cloud service from MongoDB.

By creating this App, you will learn

  • How to design GraphQL schema.
  • How to design Queries and Mutations.
  • How to build a CRUD app using GraphQL API.

Initial Setup

Create a new project using npm

npm init -y

This command will set the default value in package.json


The current version of Node.js added support for Top-Level Await just like Deno.js, and other languages like C#.

Image for post
Image for post

Now, It’s now possible to use the await keyword outside of async functions.

Let’s take a look at an example.

We will fetch a quote from API.

Installation:

Download and Install Node.js v14.3.0

Setup:

Create Node.js project using :

npm init — yes

Now install the Axios library for fetching data from API.

npm install axios --save

Now modify apackage.json file.

Take a look here, we added type as module . Because the language has not fully implemented it yet stage 3.

Code goes like this,

Running this file using node --harmony-top-level-await top-level-async-await.js .

Output:


In this blog, we will create a thread for CPU extensive tasks that not blocking the main event loop.

Image for post
Image for post

As we know, Node.js is a JavaScript runtime environment and runs the V8 JavaScript engine, the core of Google Chrome, outside of the browser.

A Node.js app is run in a single process and JavaScript doesn’t support threading, then How we can do CPU extensive and long-running tasks without blocking the main event loop?

Is it really Node.js single-threaded?

Not really, Your JavaScript is not support threading but not Node.js, Node.js internally uses C++, recent addition of Node.js …


In this blog, we will learn to implement reverse proxy for NodeJS server

Image for post
Image for post

Proxy Server

Proxy is the server that sits in between a client and an actual server.


In this blog, we will learn to build COVID19 SMS Tracker using external API and Twilio.

programmer women
programmer women

Let’s get started,

Install the required packages

npm install --save express twilio axios

We will be using an external REST API to get COVID19 Cases.

https://api.covid19api.com/

First, get the latest COVID19 cases for India using Axios.

const covidINdata = await axios.get('https://api.covid19api.com/live/country/india/status/confirmed');const latestData = covidINdata.data;//API returns array which contains all snapshots of cases. We will use latest, means last element of array.
const data = latestData[latestData.length - 1];

Now configure, Twilio SMS API

Signup for Twilio, and get Account ID and API KEY.

const ACCOUNT_ID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const API_KEY =…


Redis is an in-memory data structure used for cache. In this blog, we will implement a simple NodeJS app that uses Redis.

Image for post
Image for post

What is Redis?

Redis is an open-source, in-memory data structure store, used as a NoSQL database for the cache to improve the overall response rate for most frequently requested data.

In this blog, we will develop Notes Taking App API, We will implement two feature,

  1. Take a note from the user.
  2. Return a note back to the user.

But here will use Redis, to cache note. If the user requests the same note frequently, we will return note stored in Redis.

REST API…


In this tutorial, We will learn to protect REST APIs using JSON Web Token with an example.

Image for post
Image for post

What is JSON Web Token aka JWT?

JSON Web Token (JWT) is way of authenticating user on internet. As name suggest it is JSON based taken. The token is signed using private secret key or public key. For example, a server could generate token which user login and provide to the client. This token could signed using user_id or email with secret key and expiration timestamp. This token payload used when client need to authenticate on server.

JWT is mostly useful for REST APIs, mobile apps, Single Page Web Apps, etc. …


OS module provides information related to the operating system and hardware.

Image for post
Image for post

The os module provides API for getting information about hardware related like CPU, memory, directories, IP address and many more.

In this tutorial, we will learn basics methods and some more concepts of os module.

To start working with the os module, we have to import osmodule in our project.

const os = require('os);

os.arch()

This method will return the architecture of the processor.

const os = require('os');console.log(os.arch());

Output:

x64

os.cpus()

This method returns an array of the object which contains information of logical CPUs.

const os = require('os);console.log(os.cpus());

Output…


The fsmodule provides us API to interact with the File System of the operating system (Server).

Image for post
Image for post

The fs module provides API for interacting with the file system of the operating system. All file operations may synchronous or asynchronous I/O operations. Asynchronous methods take the fist parameter as error and the last parameter as a callback.

In this tutorial, we will learn basics operations and some more concepts of fs module.

Basics I/O operations

  1. Reading file
  2. Writing file
  3. Opening file
  4. Deleting file
  5. Renaming file
  6. Copying files

To start working with the file system, we have to import fs module in our project.

const fs =…


In this article, we will look at how to design REST APIs to be easily understandable.

Image for post
Image for post

What is REST?

REST is an acronym for REpresentational State Transfer. It is an architectural style for distributed hypermedia systems and was first presented by Roy Fielding in 2000.

REST APIs are one of the most commonly used web services in the modern world. They allow browsers, mobile apps to communicate with the server.

That’s why the proper design of REST APIs is important. Proper design help to scale, manage our backend services. Otherwise, we create problems for clients that use our APIs.

We will discuss some common design examples. We will be using the NodeJS and ExpressJS framework for this tutorial. …

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