Sign in

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

In this article, we will take a look at accessing the Redis database directly from your client app.

In this article, we will implement an event booking application, which will include the following features:

  1. Creating an event in the database.
  2. Pushing events to the cache.
  3. Cache trending events, so we will run the CRON job for updating trending events in cache periodically.
  4. On the client-side React app, we will be fetching trending events directly from the Redis server using GraphQL, ie, no need to connect with the actual server.
REST API Routes 1. POST => /api/events => Create events 2…


Redis is an in-memory data structure used for cache. In this blog, we will implement a simple Node.js app that uses Serverless Redis, and also we will be using Upstash — Serverless
Database for Redis.

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 notes stored in Redis.

REST API Routes1. POST => /api/notes => Create notes
2. GET => /api/notes/:id => Get a note

Software Requirements

Let’s begin,


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.

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…


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

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.

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

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.


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

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…


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

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());


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

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…

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