<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rajdeep Das</title>
    <description>The latest articles on DEV Community by Rajdeep Das (@rajdeepdas).</description>
    <link>https://dev.to/rajdeepdas</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F162090%2F1f660a91-5b8c-400a-b177-b91ccf57141d.jpeg</url>
      <title>DEV Community: Rajdeep Das</title>
      <link>https://dev.to/rajdeepdas</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajdeepdas"/>
    <language>en</language>
    <item>
      <title>Build a simple fileserver in 1 line using go</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Sun, 21 Jan 2024 13:14:51 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/build-a-simple-fileserver-in-1-line-using-go-58p0</link>
      <guid>https://dev.to/rajdeepdas/build-a-simple-fileserver-in-1-line-using-go-58p0</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Rc5Q8Q6L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2A_-g25_-ZR76jyONj" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rc5Q8Q6L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2A_-g25_-ZR76jyONj" alt="" width="800" height="477"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by imgix on Unsplash&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You have probably heard that Go is fantastic for building web applications of all shapes and sizes. This is partly due to the fantastic work that has been put into making the standard library clean, consistent, and easy to use.&lt;/p&gt;

&lt;p&gt;If you’re just starting with web development in Go, the net/http package is super important. It helps you create servers for the web using simple and powerful building blocks.&lt;/p&gt;
&lt;h3&gt;
  
  
  The http.Handler Interface
&lt;/h3&gt;

&lt;p&gt;As you become more familiar with Go, you will notice how much of an impact &lt;em&gt;interfaces&lt;/em&gt; make in the design of your programs. The net/http interface encapsulates the request-response pattern in one method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Handler interface {
    ServeHTTP(ResponseWriter, *Request)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Implementors of this interface are expected to inspect and process data coming from the http.Request object and write out a response to the http.ResponseWriter object.&lt;/p&gt;

&lt;p&gt;The http.ResponseWriter interface looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type ResponseWriter interface {
    Header() Header
    Write([]byte) (int, error)
    WriteHeader(int)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Often, you just want to share simple web pages with pictures and styles. Imagine you have a basic webpage with text, images, and design, and you just want to show it to others on the internet. That’s where serving static files comes in handy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
 "fmt"
 "net/http"
)

func main() {
 fmt.Println("FileServer Stared on Port : 8080")
 // "." - current directory where the progam is running
 http.ListenAndServe(":8080", http.FileServer(http.Dir("."))) 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The http.ListenAndServe function is used to start the server, it will bind to the address we gave it (:8080) and when it receives an HTTP request, it will hand it off to the http.Handler that we supply as the second argument. In our case, it is the built-in http.FileServer.&lt;/p&gt;

&lt;p&gt;The http.FileServer function builds an http.Handler that will serve an entire directory of files and figure out which file to serve based on the request path. We told the FileServer to serve the current working directory with http.Dir(".").&lt;/p&gt;

&lt;p&gt;If we go to &lt;em&gt;localhost:8080/main.go&lt;/em&gt; in our web browser, we’ll see what’s inside our main.go file. With just one line of Go code, we can run this program from any folder and turn our computer into a simple server that shares files, like a tree of files, with others.&lt;/p&gt;

&lt;p&gt;Checkout the project — &lt;a href="https://github.com/Rajdeep-Das/go-networking"&gt;Rajdeep-Das/go-networking: Go Lang Networking Stand Lib &amp;amp; Cloud Native Networking Projects (github.com)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy reading 📖. 😃&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>cloudnative</category>
      <category>networking</category>
      <category>go</category>
    </item>
    <item>
      <title>Vite 4.0 Takes Development to a Whole New Level: Faster, Smarter, and More Efficient</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Wed, 11 Jan 2023 08:26:35 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/vite-40-takes-development-to-a-whole-new-level-faster-smarter-and-more-efficient-kf8</link>
      <guid>https://dev.to/rajdeepdas/vite-40-takes-development-to-a-whole-new-level-faster-smarter-and-more-efficient-kf8</guid>
      <description>&lt;p&gt;Experience Lightning-Fast Development with Vite 4.0 and React: The Perfect Match&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2A4d3XNLeulg9X8lOR" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F0%2A4d3XNLeulg9X8lOR" width="1024" height="683"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by Lautaro Andreani on Unsplash&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Vite is a new front-end development tool that addresses the performance issues associated with current JavaScript-based toolings like webpack, Rollup, and Parcel. By leveraging the availability of native ES modules in the browser and utilizing JavaScript tools written in compile-to-native languages.&lt;/p&gt;

&lt;p&gt;Vite aims to improve developers’ productivity and happiness by reducing the wait times associated with spinning up a dev server and reflecting file edits in the browser, often seen in large-scale projects with thousands of modules.&lt;/p&gt;

&lt;p&gt;Vite, the front-end development tool, saw tremendous growth and adoption over the past five months. The number of npm downloads per week has doubled from 1 million to 2.5 million and usage among the community in the Jamstack Conf survey jumped from 14% to 32% with a high satisfaction score of 9.7.&lt;/p&gt;

&lt;p&gt;Vite-powered frameworks such as &lt;strong&gt;Astro 1.0&lt;/strong&gt; , &lt;strong&gt;Nuxt 3&lt;/strong&gt; , &lt;strong&gt;SvelteKit&lt;/strong&gt; , &lt;strong&gt;Solid Start&lt;/strong&gt; , and &lt;strong&gt;Qwik&lt;/strong&gt; are also growing and collaborating. Storybook, Deno, and &lt;strong&gt;Nx&lt;/strong&gt; also announced first-class support and investment in the Vite ecosystem. This upward trend is set to continue with &lt;strong&gt;Vitest&lt;/strong&gt; adoption also rising, it’s expected to represent half of Vite’s npm downloads soon.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Start experimenting with Vite 4.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm create vite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fincli1duehy3qqgu3l8q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fincli1duehy3qqgu3l8q.png" width="800" height="498"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;React Vite Template&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  New React plugin using SWC during development&lt;a href="https://vitejs.dev/blog/announcing-vite4.html#new-react-plugin-using-swc-during-development" rel="noopener noreferrer"&gt;#&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://swc.rs/" rel="noopener noreferrer"&gt;SWC&lt;/a&gt; is now a mature replacement for &lt;a href="https://babeljs.io/" rel="noopener noreferrer"&gt;Babel&lt;/a&gt;, especially in the context of React projects. SWC’s React Fast Refresh implementation is a lot faster than Babel, and for some projects, it is now a better alternative. From Vite 4, two plugins are available for React projects with different tradeoffs. We believe that both approaches are worth supporting at this point, and we’ll continue to explore improvements to both plugins in the future.&lt;/p&gt;

&lt;p&gt;Learn more about SWC at &lt;a href="https://swc.rs/" rel="noopener noreferrer"&gt;https://swc.rs/&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  @vitejs/plugin-react&lt;a href="https://vitejs.dev/blog/announcing-vite4.html#vitejs-plugin-react" rel="noopener noreferrer"&gt;#&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/vitejs/vite-plugin-react" rel="noopener noreferrer"&gt;@vitejs/plugin-react&lt;/a&gt; is a plugin that uses esbuild and Babel, achieving fast HMR with a small package footprint and the flexibility of being able to use the Babel transform pipeline.&lt;/p&gt;
&lt;h3&gt;
  
  
  @vitejs/plugin-react-swc (new)&lt;a href="https://vitejs.dev/blog/announcing-vite4.html#vitejs-plugin-react-swc-new" rel="noopener noreferrer"&gt;#&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/vitejs/vite-plugin-react-swc" rel="noopener noreferrer"&gt;@vitejs/plugin-react-swc&lt;/a&gt; is a new plugin that uses esbuild during build but replaces Babel with SWC during development. For big projects that don’t require non-standard React extensions, cold start and Hot Module Replacement (HMR) can be significantly faster.&lt;/p&gt;

&lt;p&gt;Let’s switch our project to use SWC (plugin-react-swc)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pnpm i -D @vitejs/plugin-react-swc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change import in vite.config.js&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdrls3n823hxf048vogwb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdrls3n823hxf048vogwb.png" width="800" height="328"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;vite.config.js&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { defineConfig } from 'vite'
//import react from '@vitejs/plugin-react'
import react from "@vitejs/plugin-react-swc";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp18fqumkl7qgwzfnz5vu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp18fqumkl7qgwzfnz5vu.png" width="800" height="446"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;React Vite SWC Project&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Official Caveats (From Github)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/vitejs/vite-plugin-react-swc" rel="noopener noreferrer"&gt;https://github.com/vitejs/vite-plugin-react-swc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This plugin has limited options to enable good performances and be transpiler agnostic. Here is the list of non-configurable options that impact runtime behavior:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier" rel="noopener noreferrer"&gt;useDefineForClassFields&lt;/a&gt; is always activated, as this matches the current ECMAScript spec&lt;/li&gt;
&lt;li&gt;jsx runtime is always automatic&lt;/li&gt;
&lt;li&gt;In development:&lt;/li&gt;
&lt;li&gt;esbuild is disabled, so the &lt;a href="https://vitejs.dev/config/shared-options.html#esbuild" rel="noopener noreferrer"&gt;esbuild configuration&lt;/a&gt; has no effect&lt;/li&gt;
&lt;li&gt;target is es2020&lt;/li&gt;
&lt;li&gt;JS files are not transformed&lt;/li&gt;
&lt;li&gt;tsconfig is not resolved, so properties other than the ones listed above behave like TS defaults&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Importing CSS as a String (From Official Website)
&lt;/h3&gt;

&lt;p&gt;In Vite 3, importing the default export of a .css file could introduce a double loading of CSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import cssString from './global.css'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This double loading could occur since a .css file will be emitted and it's likely that the CSS string will also be used by the application code — for example, injected by the framework runtime. From Vite 4, the .css default export &lt;a href="https://github.com/vitejs/vite/issues/11094" rel="noopener noreferrer"&gt;has been deprecated&lt;/a&gt;. The ?inline query suffix modifier needs to be used in this case, as that doesn't emit the imported .css styles.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import stuff from './global.css?inline'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Environment Variables (From Official Website)
&lt;/h3&gt;

&lt;p&gt;Vite now uses dotenv 16 and dotenv-expand 9 (previously dotenv 14 and dotenv-expand 5). If you have a value including # or `, you will need to wrap them with quotes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
-VITE_APP=ab#cd&lt;/code&gt;ef&lt;br&gt;
+VITE_APP="ab#cd&lt;code&gt;ef"&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For more details, see the &lt;a href="https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md" rel="noopener noreferrer"&gt;dotenv&lt;/a&gt; and &lt;a href="https://github.com/motdotla/dotenv-expand/blob/master/CHANGELOG.md" rel="noopener noreferrer"&gt;dotenv-expand changelog&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Summary
&lt;/h4&gt;

&lt;p&gt;Vite is a lightweight development server that is designed to be fast and easy to use. The latest version, Vite 4.0, brings a number of new features and improvements that make it an even more powerful tool for building web applications. Here are a few reasons why developers might want to give Vite 4.0 a try:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Speed&lt;/strong&gt; : Vite is incredibly fast, thanks to its native ES module support and its ability to perform hot module replacement (HMR) without a webpack configuration. This makes development faster and more efficient, as you don’t have to wait for long build times or manually refresh the page to see your changes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simplicity&lt;/strong&gt; : Vite is easy to set up and use, with minimal configuration required. This means developers can get up and running quickly, without having to spend a lot of time on setup. Additionally, since it’s built on top of native ES modules, it requires minimal configuration and dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexibility&lt;/strong&gt; : Vite is highly customizable, with a range of options and plugins available. This allows developers to tailor their workflow to their specific needs. Additionally, Vite 4.0 has introduced a rollup and webpack plugin for even more flexibility.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Great Community&lt;/strong&gt; : Vite has a growing community of developers who contribute to the project and also provides a lot of plugins that you can use to enhance your development experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Given these benefits, developers who are looking for a fast, easy-to-use, and flexible development server should definitely give Vite 4.0 a try.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reference:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://vitejs.dev/blog/announcing-vite4.html" rel="noopener noreferrer"&gt;https://vitejs.dev/blog/announcing-vite4.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://swc.rs/" rel="noopener noreferrer"&gt;https://swc.rs/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/rajdeep-das-india/" rel="noopener noreferrer"&gt;Rajdeep Das | LinkedIn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://rajdeep-das.com" rel="noopener noreferrer"&gt;Software Developer | Rajdeep Software Engineering &amp;amp; Consulting Services&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vites</category>
      <category>javascript</category>
      <category>react</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Serverless Stack for Cost-Effective Architecture on AWS</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Mon, 02 Jan 2023 09:36:39 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/serverless-stack-for-cost-effective-architecture-on-aws-4k5f</link>
      <guid>https://dev.to/rajdeepdas/serverless-stack-for-cost-effective-architecture-on-aws-4k5f</guid>
      <description>&lt;p&gt;Considering serverless stack for simplified cost-effective app development&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CpUfx-uM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2A4wXDp7HqdKZpLX2V" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CpUfx-uM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2A4wXDp7HqdKZpLX2V" alt="" width="800" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Serverless computing is a cloud computing model that allows developers to build and deploy applications more quickly and cost-effectively than traditional approaches. Serverless Stack is a combination of cloud-native technologies and best practices that enable developers to take advantage of the scalability, security, and cost benefits offered by cloud platforms such as Amazon Web Services (AWS). In this blog, we’ll discuss the benefits of using Serverless Stack on AWS and offer tips for SMEs and entrepreneurs building cloud-native applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;Serverless Stack is a combination of cloud-native technologies and best practices that enable developers to build and deploy applications more quickly and cost-effectively than traditional approaches. It leverages serverless computing, which is a cloud computing model that allows developers to build and deploy applications without managing servers or infrastructure. With serverless computing, developers only pay for the resources they use, making it a more cost-effective approach than traditional server-based architectures.&lt;/p&gt;

&lt;p&gt;The benefits of using a Serverless Stack include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Low cost — Serverless Stack can significantly reduce the cost of deploying and running applications as compared to traditional approaches.&lt;/li&gt;
&lt;li&gt;Easy to scale — Serverless Stack makes it easy to scale applications quickly and easily without the need for additional hardware or software.&lt;/li&gt;
&lt;li&gt;Flexible — Serverless Stack allows developers to quickly adjust their architecture to meet changing needs without having to make costly changes to their existing code.&lt;/li&gt;
&lt;li&gt;Automation — Serverless Stack automates many of the tedious tasks involved in deploying and maintaining applications, allowing developers to focus on building new features instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Solution Architecture
&lt;/h3&gt;

&lt;p&gt;AWS provides a variety of services, including computing, storage, databases, analytics, and machine learning, which are all available to leverage when creating a cost-effective architecture on AWS. To take advantage of these services, developers can utilize AWS services such as Lambda, DynamoDB, and API Gateway to create a serverless architecture that is cost-effective and can scale with demand. Additionally, developers can leverage AWS services such as CloudFormation to automate the deployment of their applications. Finally, developers can also utilize AWS services such as CloudWatch for monitoring and alerting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Development
&lt;/h3&gt;

&lt;p&gt;When building cloud-native applications, it’s important to understand the advantages of using microservices. Microservices are small, independently deployable components that can be combined to create larger, more complex applications. The advantages of using microservices include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster development — Microservices allow teams to develop and deploy code more quickly than traditional monolithic architectures.&lt;/li&gt;
&lt;li&gt;Easier maintenance — Microservices also make it easier to maintain and update code over time, since each microservice can be updated independently of other services.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To ensure secure access to APIs hosted on AWS, developers can utilize Amazon API Gateway. API Gateway is a service that provides secure access to APIs hosted on AWS. It allows developers to control who has access to their APIs and how they can access them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In conclusion, Serverless Stack is a combination of cloud-native technologies and best practices that enable developers to build and deploy applications more quickly and cost-effectively than traditional approaches. The benefits of using a Serverless Stack include low cost, easy scalability, flexibility, and automation. To create a cost-effective architecture on AWS, developers should utilize AWS services such as Lambda, DynamoDB, API Gateway, CloudFormation, and CloudWatch; use microservices; take advantage of the scalability, security, and cost benefits offered by cloud platforms; and automate the deployment of their application with tools such as CloudFormation. SMEs and entrepreneurs building cloud-native applications should keep these tips in mind when designing their architecture.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at&lt;/em&gt; &lt;a href="https://www.linkedin.com/pulse/serverless-stack-cost-effective-architecture-aws-rajdeep-das"&gt;&lt;em&gt;https://www.linkedin.com&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>fullstackdeveloper</category>
      <category>serverless</category>
      <category>softwareengineering</category>
      <category>microservices</category>
    </item>
    <item>
      <title>Filters in ASP.NET Core</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Wed, 14 Dec 2022 19:18:26 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/filters-in-aspnet-core-31h6</link>
      <guid>https://dev.to/rajdeepdas/filters-in-aspnet-core-31h6</guid>
      <description>&lt;p&gt;How To Create Custom Action Filter In ASP.NET 6 &amp;amp; Above&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Filters&lt;/em&gt; in ASP.NET Core allow code to run before or after specific stages in the request processing pipeline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inbuild Filters&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authorization prevents access to resources a user isn’t authorized for.&lt;/li&gt;
&lt;li&gt;Response caching, short-circuiting the request pipeline to return a cached response.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Custom Filters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Custom filters can be created to handle cross-cutting concerns. Examples of cross-cutting concerns include error handling, caching, configuration, authorization, and logging. Filters avoid duplicating code. For example, an error-handling exception filter could consolidate error handling.&lt;/p&gt;

&lt;p&gt;There are many filters in ASP.NET Core, but we will focus on Action Filters&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-7.0#action-filters"&gt;Action filters&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run immediately before and after an action method is called.&lt;/li&gt;
&lt;li&gt;Can change the arguments passed into action.&lt;/li&gt;
&lt;li&gt;Can change the result returned from the action.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How Filters Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Filters run within the ASP.NET Core action invocation pipeline, sometimes referred to as the filter pipeline. The filter pipeline runs after ASP.NET Core selects the action to execute:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CxhWhoGW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/336/1%2AS-NXC-_8zmtOeyhsk2FW7w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CxhWhoGW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/336/1%2AS-NXC-_8zmtOeyhsk2FW7w.png" alt="" width="336" height="554"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;ASP.NET Filters&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We can implement Action Filters as synchronous and asynchronous through different interface definitions&lt;/p&gt;

&lt;p&gt;We are going to build a SingleDeviceSessionCheck Filter for example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace MyService.UserApi.Filters
{
  public class SingleDeviceCheck : IActionFilter
  {
      private readonly IDeviceAccessRepository deviceAccessRepository;
      private readonly ILogger&amp;lt;SingleDeviceCheck&amp;gt; logger;
      private readonly IConfiguration configuration;

      /* Constructor for DI */ 
      public SingleDeviceCheck(
      /* This Respository Containts logic for checking session in DB */
          IDeviceAccessRepository deviceAccessRepository,
          ILogger&amp;lt;SingleDeviceCheck&amp;gt; logger,
          IConfiguration configuration)
      {
          this.deviceAccessRepository = deviceAccessRepository;
          this.logger = logger;
          this.configuration = configuration;
      }
  }
   // our code before action executes
   public void OnActionExecuting(ActionExecutingContext context){}
   // our code after action executes
   public void OnActionExecuted(ActionExecutedContext context){}
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to implement our logic in these two methods, for my use case I required the onActionExecuting method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public void OnActionExecuting(ActionExecutingContext context)
{
  // Checking single device access ON or OFF (Feature Flag For Dev/Prod Test
  if (this.configuration["SD_ON_OFF"].Equals("OFF")) { return; }

  // our code before action executes
  var deviceId = context.HttpContext.Request?.Headers["Device-Id"];
  if (string.IsNullOrEmpty(deviceId.ToString()))
  {
      context.Result = new BadRequestObjectResult("Device-Id is empty");
      return;
  }
  // if same device login then permission granted
  // Read USER INFO From JWT Claims
  var email = context.HttpContext.User.FindFirst("https://xyz.com/email")?.Value;
  var deviceAccessData = deviceAccessRepository.GetActiveDeviceByEmailAsync(email).Result;
  if (deviceAccessData == null)
  {
      context.Result = new UnauthorizedObjectResult(new { status = false, message = "Couldn't Find Your Device. Please Logout &amp;amp; Login Again." })
      {
          StatusCode = 403
      };
      return;
  }
  if (!(deviceAccessData.DeviceId == deviceId.ToString() &amp;amp;&amp;amp; deviceAccessData?.IsActive == true))
  {
      logger.LogInformation("Device Failed To Pass {device} and {email}", deviceId, email);
      context.Result = new UnauthorizedObjectResult(new { status = false, message = "You have already active in another device.\n Access Denied." })
      {
          StatusCode = 403
      };
      return;
  }
  else
  {
      logger.LogInformation("Device Pass {device} and {email}", deviceId, email);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will register our Action Filter in Program. cs or Startup.cs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public void ConfigureServices(IServiceCollection services)
{
  services.AddDbContext&amp;lt;MovieContext&amp;gt;(options =&amp;gt;
   options.UseSqlServer(Configuration.GetConnectionString("sqlConString")));
  //Filters 
  services.AddScoped&amp;lt;SingleDeviceCheck&amp;gt;();
  services.AddControllers();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we will use This Filter In Our Controller&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Dev Test Only
[HttpGet("device")]
//Filter Code Run in Request Pipeline
[ServiceFilter(typeof(SingleDeviceCheck))]
public IActionResult CheckDevieID() {
    return Ok("Single Device ID Endpint Check");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Action Filter helps us to reuse code.&lt;/li&gt;
&lt;li&gt;Run Some Common Logic In SPecific Controller or Methods In the Request Pipeline&lt;/li&gt;
&lt;li&gt;A middleware can run for all requests while filters will only run for requests that reach the EndpointMiddleware&lt;/li&gt;
&lt;li&gt;filters will only run on specified actions and controllers unless you register the filter globally in the startup. Since you have full access to the context you can also access the controller and action itself.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I always recommend using Action Filters because they give us reusability in our code and cleaner code in our actions as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://rajdeep-das.com"&gt;Software Developer | Rajdeep Software Engineering &amp;amp; Consulting Services&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/rajdeep-das-india/"&gt;Rajdeep Das | LinkedIn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank You, happy reading 📖 , 😊&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>aspnetcore</category>
      <category>restapi</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Create Logger for Microservices Powered By RedisSearch &amp; RedisJSON</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Thu, 15 Sep 2022 12:19:49 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/create-logger-for-microservices-powered-by-redissearch-redisjson-4pbl</link>
      <guid>https://dev.to/rajdeepdas/create-logger-for-microservices-powered-by-redissearch-redisjson-4pbl</guid>
      <description>&lt;h4&gt;
  
  
  A Lightweight Dot Net Realtime Message, Event, HTTP (Request &amp;amp; Response) and Exception Logger For Web (Trying to make centralised logger for Microservice and K8s environment)
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2yinNvsy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/700/1%2AwPD6Ta4X7ZJYXlz622vxJg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2yinNvsy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/700/1%2AwPD6Ta4X7ZJYXlz622vxJg.png" alt="banner" width="700" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’m searching for a logger and a simple UI to view my HTTP request &amp;amp; response logs in microservice environments. I found something called &lt;a href="https://www.elastic.co/"&gt;&lt;em&gt;elastic-search&lt;/em&gt;&lt;/a&gt;, where all logs are stored &amp;amp; it gives a nice UI to view.&lt;/p&gt;

&lt;p&gt;But for my simple APP &amp;amp; Low User base, Elastic search setup &amp;amp; operation cost are so high for my requirements. so I decided to build my simple logger, nothing fancy or complicated.&lt;/p&gt;

&lt;p&gt;The idea is to build a simple &lt;strong&gt;Middleware&lt;/strong&gt; that logs all the HTTP requests &amp;amp; responses. Then store the logs in DB for View Later. Create an &lt;strong&gt;Extension Method&lt;/strong&gt; to register this middleware in HTTP Pipeline &amp;amp; Publish this middleware as &lt;a href="https://www.nuget.org/"&gt;&lt;strong&gt;Nuget&lt;/strong&gt;&lt;/a&gt; Package.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My Requirements are&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I want a simple temporary log storage max 7–14 Days Logs.&lt;/li&gt;
&lt;li&gt;Very Lightweight to set up, and operate and has low memory usage.&lt;/li&gt;
&lt;li&gt;It just does two things record all HTTP request &amp;amp; response data, and exception logs for my microservices which are written in ASP.NET Core (.NET 6).&lt;/li&gt;
&lt;li&gt;A Simple UI where I can search &amp;amp; view logs by service name, request methods, timestamp, etc filter.&lt;/li&gt;
&lt;li&gt;I don’t want to use my primary application, DB, to store temporary logs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;How I build&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When searching on the internet I found something called &lt;a href="https://redis.io/docs/stack/search/"&gt;&lt;strong&gt;RedisSearch&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;.&lt;/strong&gt; &lt;em&gt;RediSearch is a Full-Text Search Engine for NoSQL Database.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;According to Redis Website, &lt;strong&gt;RediSearch&lt;/strong&gt; is powerful indexing, querying, and full-text search engine for Redis, available on-premises and as a managed service in the cloud.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Everyone knows what is &lt;strong&gt;Redis&lt;/strong&gt; (At least for those who are in the web development field for the last few years). Redis is a very popular cache but &lt;strong&gt;Redis&lt;/strong&gt; also can be used as Primary Database, it supports JSON Documents like MongoDB (No-SQL Database). We can enable these features by installing &lt;strong&gt;Redis JSON&lt;/strong&gt;  Module.&lt;/p&gt;

&lt;p&gt;This is the perfect choice for my requirements because I want nice search capabilities, I want search data in the HTTP request &amp;amp; response body and I don’t want a strong schema because HTTP request and response bodies vary from service to service but at the same time I also want strong search functionality.&lt;/p&gt;

&lt;h4&gt;
  
  
  Let’s Get Started
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Let’s set up Redis, we are going to use the Redis cloud for easy setup, and quickly get started with &lt;strong&gt;RedisJSON&lt;/strong&gt; &amp;amp; &lt;strong&gt;RedisFullText&lt;/strong&gt; Search Module.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redis Enterprise Cloud&lt;/strong&gt; provides performance, operational simplicity, data management, and security in the cloud. &lt;a href="https://redis.com/redis-enterprise-cloud/overview/"&gt;https://redis.com/redis-enterprise-cloud/overview/&lt;/a&gt;. Don’t worry it provides a free tier for quickly building &amp;amp; prototype your solution. You can choose your favorite cloud provider &amp;amp; region. I’m Going to choose AWS and AP-South-1.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6VON6uzA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AZFt7QXB4nqY0cn7CYtNKBg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6VON6uzA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AZFt7QXB4nqY0cn7CYtNKBg.png" alt="Redis Enterprise " width="800" height="371"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Redis Enterprise Cloud&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After creating Account &amp;amp; Choosing Your RedisStack Deployment, You will get a public endpoint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---wVp_orF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AyaHw9oaEw9JwtdaFFIasVA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---wVp_orF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AyaHw9oaEw9JwtdaFFIasVA.png" alt="Redis Enterprise Cloud" width="800" height="380"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Redis Public Endpoint&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We will use &lt;a href="https://redis.com/redis-enterprise/redis-insight/"&gt;&lt;strong&gt;RedisInsight&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;.&lt;/strong&gt; A Redis GUI tool to connect to Redis cloud instance.RedisInsight enables the use of Redis data types including JSON and time series by providing a new user interface, a browser tool, a sophisticated CLI, bespoke data visualization, and built-in tutorials.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DwGTglzu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2A-Q5oLwLhKbAi0KVwy8uvHQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DwGTglzu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2A-Q5oLwLhKbAi0KVwy8uvHQ.png" alt="Redisinsight" width="800" height="505"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Redisinsight&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redis Enterprise&lt;/strong&gt; enables you to create backups across all database shards quickly and consistently. It achieves quick auto-cluster recovery by rebuilding the cluster from the configuration file and using the same endpoints and database configurations.&lt;/p&gt;

&lt;p&gt;Instant disaster recovery is achieved through Active-Active deployment, which allows reading and writing to each replica at any time and is backed up by an academically proven conflict-resolution mechanism.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quick Overview of Redis JSON &amp;amp; Get Started&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can interact with Redis JSON documents using Redis CLI or Redis CLI available on RedisInsight GUI Tool.&lt;/p&gt;

&lt;p&gt;To interact with Redis JSON we most often use JSON.GET &amp;amp; JSON.SET Commands from CLI&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WsVVGKFH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2A1v09vveG-mA1B8TyRgbJtQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WsVVGKFH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2A1v09vveG-mA1B8TyRgbJtQ.png" alt="Redis CLI" width="800" height="320"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Redis Insight CLI&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;According to Redis DOCS &amp;amp; Website Redis.JSON GET &amp;amp; SET Commands specification.&lt;/p&gt;

&lt;p&gt;Redis JSON Supported Data Structure&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scalar&lt;/li&gt;
&lt;li&gt;Objects (including nested objects)&lt;/li&gt;
&lt;li&gt;Arrays of JSON objects&lt;/li&gt;
&lt;li&gt;JSON nested objects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;JSON.GET&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JSON.GET key [INDENT indent] [NEWLINE newline] [SPACE space] [paths
[paths ...]]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Available in:&lt;br&gt;&lt;br&gt;
Redis Stack / JSON 1.0.0&lt;/p&gt;

&lt;p&gt;Time complexity:&lt;br&gt;&lt;br&gt;
O(N) when the path is evaluated to a single value where N is the size of the value, O(N) when the path is evaluated to multiple values, where N is the size of the key&lt;/p&gt;

&lt;p&gt;This command accepts multiple path arguments. If no path is given, it defaults to the value's root.&lt;/p&gt;

&lt;p&gt;The following subcommands change the reply’s format (all are empty strings by default):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;INDENT sets the indentation string for nested levels&lt;/li&gt;
&lt;li&gt;NEWLINE sets the string that's printed at the end of each line&lt;/li&gt;
&lt;li&gt;SPACE sets the string that's put between a key and a value&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3fZF3Mag--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AtzpX6W7QJB229JoKtUMzhg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3fZF3Mag--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AtzpX6W7QJB229JoKtUMzhg.png" alt="JSON.GET Result" width="800" height="359"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;JSON.GET Result&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JSON.SET&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JSON.SET key path value [NX | XX]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Available in: &lt;a href="https://redis.io/docs/stack"&gt;Redis Stack&lt;/a&gt; / &lt;a href="https://redis.io/docs/stack/json"&gt;JSON 1.0.0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Time complexity: O(M+N) when the path is evaluated to a single value where M is the size of the original value (if it exists) and N is the size of the new value, O(M+N) when the path is evaluated to multiple values where M is the size of the key and N is the size of the new value&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zxbAq5VS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AfTDl59zZ35nhzmGFflMbfg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zxbAq5VS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AfTDl59zZ35nhzmGFflMbfg.png" alt="Redis Commands" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;JSON.SET Command&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to get all keys in Redis JSON&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To list the keys in the Redis data store, use the &lt;strong&gt;KEYS&lt;/strong&gt; command followed by a specific pattern. Redis will search the keys for all the keys matching the specified pattern. In our example, we can use an asterisk (*) to match all the keys in the data store to get the keys.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0rHzUza8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AMniWUvoNCaOECu6_T3gGxg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0rHzUza8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AMniWUvoNCaOECu6_T3gGxg.png" alt="Redis Commands" width="800" height="377"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;List Keys&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To connect Redis from .NET Required Some sort of DB Driver &amp;amp; ORM.&lt;/strong&gt; &lt;a href="https://stackexchange.github.io/StackExchange.Redis/"&gt;&lt;strong&gt;StackExchange Redis&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;is popular amongst .NET Developers to connect Redis instances. But for easy use of Redis search &amp;amp; Redis JSON features, we will use&lt;/strong&gt; &lt;a href="https://github.com/redis/redis-om-dotnet"&gt;&lt;strong&gt;Redis OM&lt;/strong&gt;&lt;/a&gt;. NET.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Redis OM?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Redis OM provides high-level abstractions for using Redis in .NET, making it easy to model and query your Redis domain objects.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declarative object mapping for Redis objects&lt;/li&gt;
&lt;li&gt;Declarative secondary-index generation&lt;/li&gt;
&lt;li&gt;Fluent APIs for querying Redis&lt;/li&gt;
&lt;li&gt;Fluent APIs for performing Redis aggregations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s try to use RedisOM in Our Dotnet Application. It’s simple to use RedisJSON with ASP.NET.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create the Logs model&lt;/strong&gt;. Here you will notice that the fields are decorated with the Indexed attribute. These attributes ( &lt;strong&gt;Searchable&lt;/strong&gt; and &lt;strong&gt;Indexed&lt;/strong&gt; ) tell Redis OM that you want to be able to use those fields in queries when querying your documents in Redis Stack.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;[Document(StorageType = StorageType.Json, Prefixes = new []{“WLog”})] Indicates that the data type that Redis OM will use to store the document in Redis is JSON and that the prefix for the keys for the WLog class will be WLog.&lt;/p&gt;

&lt;p&gt;The Id property is marked as a RedisIdField. This denotes the field as one that will be used to generate the document’s key name when it’s stored in Redis. e,g Id:”01GC92PD10R0DFVST9CV6Q7SBS”&lt;/p&gt;

&lt;p&gt;To insert your object into Redis, use Set on the RedisConnection or Insert in the RedisCollection. Redis OM will automatically set the id for you and you will be able to access it in the object. If the Id type is a string and no IdGenerationStrategy is explicitly overridden on the thing, the ULID will bind to the string.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--A4XP8g5g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AOXaLMHMrv5yfr768bqWCJg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A4XP8g5g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2AOXaLMHMrv5yfr768bqWCJg.png" alt="Redis JSON" width="800" height="707"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;WLog.cs to RedisJSON&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After you’ve finished building the model, you’ll need to construct the &lt;em&gt;index&lt;/em&gt; in Redis. The best method to handle this is to spin the index creation out into a Hosted Service that will execute when the app is launched. Make a directory called ‘HostedServices’ and add &lt;em&gt;IndexCreationService.cs&lt;/em&gt; to it. Add the following to that file to construct the index on startup.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Redis OM handles connections to Redis and offers the classes you may use to communicate with Redis via the RedisConnectionProvider class. To utilize it, just inject a RedisConnectionProvider object into your application.&lt;/p&gt;

&lt;p&gt;Let’s Create a Helper Class That will contain DB Access Logic. One Of the great features I like about Redis OM, we can easily query using LINQ expression. I used Object Mapper to Convert Domain Model to Redis DB Models. In the future, if we want to support other DB, we can easily do that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public IEnumerable&amp;lt;WatchLog&amp;gt; FilterByMethod(string method){ var logs = _redisWatchLog.Where(x =&amp;gt; x.Method == method).ToList(); List&amp;lt;WatchLog&amp;gt; logList = CustomMapper.Mapper.Map&amp;lt;List&amp;lt;WLog&amp;gt;, List&amp;lt;WatchLog&amp;gt;&amp;gt;(logs);            
return logList;                        
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Import Note About Redis OM .NET&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Redis OM may be used in conjunction with normal Redis for object mapping and retrieving objects by ID. Redis OM is dependent on the Redis Stack platform for more sophisticated functionality like indexing, querying, and aggregation. The Redis Stack platform is a collection of modules that expand Redis.&lt;/p&gt;

&lt;p&gt;Why is this significant?&lt;br&gt;&lt;br&gt;
You can still use Redis OM to develop declarative models supported by Redis if you don’t have Redis Stack.&lt;/p&gt;

&lt;p&gt;We’ll store your model data as Hashes in Redis, and you’ll be able to retrieve models using their main keys.&lt;/p&gt;

&lt;p&gt;So, what won’t operate in the absence of Redis Stack?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Models cannot be nested inside each other.&lt;/li&gt;
&lt;li&gt;You will not be able to discover objects using our expressive queries; you will only be able to query by primary key.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As We are Building A Logger Libray as Middleware, the Injection code is written in Service Collection Extension Method.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We Register the RedisConnection provider as a singleton.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;services.AddSingleton(new RedisConnectionProvider(WatchLogExternalDbConfig.ConnectionString));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will retrieve your connection string from the configuration and initialize the provider. The provider is now accessible for usage in your controllers/services.&lt;/p&gt;

&lt;p&gt;Now we will create the leading &lt;strong&gt;Middleware&lt;/strong&gt; , That will intercept the HTTP Request &amp;amp; Response and save it to DB.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Next, To Get Logs in UI, We have to create an API, from which we will fetch logs. Let’s Create an API Controller That looks like the one below.&lt;/p&gt;

&lt;p&gt;This is a very basic simple API Idea, We will later extend it with robust Redis &lt;strong&gt;FullTextSearch&lt;/strong&gt; Methods, RealTime Streaming, etc fancy things. Keep in mind this is a Proof of concept type of Project, a very early stage in development.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now we can use This Logger in the dotnet Web API project.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Configure DB Connection In API Service
builder.Services.AddWatchLoggerServices(opt =&amp;gt;{ opt.SetExternalDbConnString = builder.Configuration["RedisConnectionString"];});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Register WatchLogger In Middleware&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Custom Logger Middleware
app.UseWatchLogger();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, We will Build A Sample UI In Angular or a Similar Framework, That will somewhat look like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3mL8wmwF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2A6umPxAaEDLlrgzdx7SUT6w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3mL8wmwF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/1%2A6umPxAaEDLlrgzdx7SUT6w.png" alt="WatchLogger UI" width="800" height="569"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;WatchLogger UI&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For UI, I am writing a separate second Part. Where we will extend Redis Stack Features, Fully Use RedisFullText Search, and RedisStream also adds Exception Logger Middleware, WebSocket, SignalR, etc.&lt;/p&gt;

&lt;p&gt;Don’t forget to try Redis, and we’ll continue the series as a Redis Stack. In forthcoming blogs, we will look at Redis Search, Redis Stream, pub-sub, and many more topics. To learn more about Redis, go to &lt;a href="https://redis.io/"&gt;https://redis.io/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Early Stage Project Available On Github: &lt;a href="https://github.com/Rajdeep-Das/WatchLogger"&gt;WatchLogger&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Rajdeep-Das/WatchLogger"&gt;GitHub - Rajdeep-Das/WatchLogger: A Lightweight Dot Net Realtime Message, Event, HTTP (Request &amp;amp; Response) and Exception Logger For Web (Trying to make centralized logger for Microservices and K8s)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post is in collaboration with Redis.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learn more about Redis Cool 😎 Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://redis.info/3NBGJRT"&gt;Try Redis Cloud for free&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://redis.info/3Ga9YII"&gt;Watch this video on the benefits of Redis Cloud over other Redis providers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://redis.info/3LC4GqB"&gt;Redis Developer Hub — tools, guides, and tutorials about Redis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://redis.info/3wMR7PR"&gt;RedisInsight Desktop GUI&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>distributedsystems</category>
      <category>aspnetcore</category>
      <category>softwareengineering</category>
      <category>redis</category>
    </item>
    <item>
      <title>JavaScript Path Documentation of Handy Methods</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Mon, 11 Jul 2022 01:35:56 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/javascript-path-documentation-of-handy-methods-1c66</link>
      <guid>https://dev.to/rajdeepdas/javascript-path-documentation-of-handy-methods-1c66</guid>
      <description>&lt;ol&gt;
&lt;li&gt;The &lt;strong&gt;find()&lt;/strong&gt; method returns the value of the first element in the provided array   that satisfies the provided testing function.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;array1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;test2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;found&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;array1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;found&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OutPut:&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;Object { id: "1", name: "test" }&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Design Restful WebServices — Part 1</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Fri, 17 Jun 2022 17:05:37 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/design-restful-webservices-part-1-17ok</link>
      <guid>https://dev.to/rajdeepdas/design-restful-webservices-part-1-17ok</guid>
      <description>&lt;h3&gt;
  
  
  Design Restful WebServices — Part 1
&lt;/h3&gt;

&lt;p&gt;Design API like end user will consume It&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nWspP1wF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2AUEaVVvSg8sjHrNdP" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nWspP1wF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2AUEaVVvSg8sjHrNdP" alt="" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by Fahim Muntashir on Unsplash&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;HTTP is an application-level protocol that defines the operation between client and server. There is a difference between designing Restful API &amp;amp; Designing API, which also uses HTTP protocols and JSON/XML for data transfer.&lt;/p&gt;

&lt;p&gt;REST is an acronym for &lt;strong&gt;R&lt;/strong&gt; epresentational &lt;strong&gt;S&lt;/strong&gt; tate &lt;strong&gt;T&lt;/strong&gt; ransfer, an architectural style for distributed hypermedia systems.&lt;/p&gt;

&lt;p&gt;In this protocol, methods such as &lt;strong&gt;GET&lt;/strong&gt; , &lt;strong&gt;POST&lt;/strong&gt; , &lt;strong&gt;PUT&lt;/strong&gt; , and &lt;strong&gt;DELETE&lt;/strong&gt; operations that act on resources.&lt;/p&gt;

&lt;p&gt;This protocol eliminates the need for you to invent application-specific operations such as &lt;strong&gt;createOrder&lt;/strong&gt; , &lt;strong&gt;getStatus&lt;/strong&gt; , &lt;strong&gt;updateStatus&lt;/strong&gt; , &lt;strong&gt;getUserInfoById,&lt;/strong&gt; etc.&lt;/p&gt;

&lt;p&gt;A Web API or Web Service that follows this type of architecture is known as a RESTful API&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 1:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You want to know how to apply those protocols GET, POST, PUT, PATCH, and DELETE on resources to achieve Restful Architecture Style.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you define the resource like Customer, Order, User, etc, use &lt;strong&gt;GET&lt;/strong&gt; to get a resource representation, &lt;strong&gt;PUT&lt;/strong&gt; to update a resource, &lt;strong&gt;DELETE&lt;/strong&gt; to delete a resource, and &lt;strong&gt;POST&lt;/strong&gt; to create a resource.&lt;/p&gt;

&lt;h4&gt;
  
  
  Role of Idempotent &amp;amp; Safe HTTP Methods in Restful Web Services &amp;amp; Implementation
&lt;/h4&gt;

&lt;p&gt;What is idempotent in the HTTP Method?&lt;/p&gt;

&lt;p&gt;We call an HTTP method idempotent if that method does not create any side effects or alter the state of the server even if we send the same request many times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GET&lt;/strong&gt;  — if we call get request on a resource many times it will not change the state of the resource, it will return the result of how many times we call it without doing any side effects&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;POST&lt;/strong&gt;  — If we call a post request multiple times it will create a new resource every time. For Example, if we send create customer resource multiple times it will every time generate a new customer and save to DB.&lt;/p&gt;

&lt;p&gt;If we Implement correctly, the GET, HEAD, PUT, and DELETE methods should be idempotent in Restful API Design. If we violate that rule then we can’t call it RESTful Standard API Design.&lt;/p&gt;

&lt;p&gt;In an idempotent check, only Backend Server State is considered. Not the Status Code.&lt;/p&gt;

&lt;p&gt;For Example&lt;/p&gt;

&lt;p&gt;The first Call of DELETE Return &lt;strong&gt;200&lt;/strong&gt; but the Second call will return  &lt;strong&gt;404&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3euzq-iP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/572/0%2AjG-KHZmfIB_NHyvX" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3euzq-iP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/572/0%2AjG-KHZmfIB_NHyvX" alt="" width="572" height="372"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;HTTP Method Table&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Happy reading… 😁😃 &lt;a href="https://www.linkedin.com/in/rajdeep-das-india/"&gt;Rajdeep Das | LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>frontend</category>
      <category>backend</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Relational Database At A Glance With PostgreSQL</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Mon, 31 May 2021 16:53:51 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/relational-database-at-a-glance-with-postgresql-3im5</link>
      <guid>https://dev.to/rajdeepdas/relational-database-at-a-glance-with-postgresql-3im5</guid>
      <description>&lt;p&gt;According to Wikipedia A &lt;strong&gt;relational database&lt;/strong&gt; is a digital &lt;a href="https://en.wikipedia.org/wiki/Database"&gt;database&lt;/a&gt; based on the &lt;a href="https://en.wikipedia.org/wiki/Relational_model"&gt;relational model&lt;/a&gt; of data, as proposed by &lt;a href="https://en.wikipedia.org/wiki/E._F._Codd"&gt;E. F. Codd&lt;/a&gt; in 1970. A software system used to maintain relational databases is a &lt;a href="https://en.wikipedia.org/wiki/Relational_database_management_system"&gt;relational database management system&lt;/a&gt; (RDBMS). Many relational database systems have an option of using the &lt;a href="https://en.wikipedia.org/wiki/SQL"&gt;SQL&lt;/a&gt; (Structured Query Language) for querying and maintaining the database&lt;/p&gt;

&lt;h4&gt;
  
  
  Database 101
&lt;/h4&gt;

&lt;p&gt;A database stores data&lt;/p&gt;

&lt;p&gt;Plain text files have limited functionality for basic processes, including:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Searches&lt;/li&gt;
&lt;li&gt;Simultaneous updates and reads&lt;/li&gt;
&lt;li&gt;Access control&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Access the text file via a management system to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Traffic management for the data&lt;/li&gt;
&lt;li&gt;Manage concurrency&lt;/li&gt;
&lt;li&gt;Provide other features&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  ACID compliance
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Atomicity&lt;/strong&gt;  — Store data in an all-or-nothing approach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consistency &lt;/strong&gt; — Give me a consistent picture of the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Isolation &lt;/strong&gt; — Prevent concurrent data updates from incorrect reads/writes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Durability &lt;/strong&gt; — When User say ‘ &lt;strong&gt;COMMIT&lt;/strong&gt; ;’ the data, make sure it is safe until User explicitly destroy it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Database transactions
&lt;/h4&gt;

&lt;p&gt;A transaction is a unit of work.&lt;/p&gt;

&lt;p&gt;A transaction is all or nothing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Beginning (BEGIN;)
Work (INSERT/UPDATE/DELETE/SELECT)
Ending (END;) results in one of the following:
COMMIT; (save everything)
ROLLBACK; (undo all changes, and save nothing)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the transaction ends, it either makes ALL of the changes between BEGIN; and COMMIT; or NONE of them (if there is an error, for example).&lt;/p&gt;

&lt;h4&gt;
  
  
  PostgreSQL 101
&lt;/h4&gt;

&lt;p&gt;PostgreSQL meets all the requirements to be a fully ACID-compliant, transactional database. To accomplish this, many database and computer science concepts are implemented. The focus of the course is to illustrate PostgreSQL internals and the effects they have on the end user.&lt;/p&gt;

&lt;p&gt;PostgreSQL relational database management system (RDBMS) serves an instance that:&lt;/p&gt;

&lt;p&gt;Serves one (and only one) TCP/IP port&lt;br&gt;&lt;br&gt;
Has a dedicated data directory&lt;br&gt;&lt;br&gt;
Contains at least one database&lt;/p&gt;

&lt;h4&gt;
  
  
  PostgreSQL features
&lt;/h4&gt;

&lt;p&gt;ACID compliant&lt;br&gt;&lt;br&gt;
 Transactional (uses WAL/REDO)&lt;br&gt;&lt;br&gt;
 Partitioning&lt;br&gt;&lt;br&gt;
 Multi version concurrency control (readers don’t block writers)&lt;/p&gt;

&lt;p&gt;Online maintenance operations&lt;br&gt;&lt;br&gt;
 Hot/warm Standby&lt;br&gt;&lt;br&gt;
 Full-text search&lt;br&gt;&lt;br&gt;
 Rich geospatial (PostGIS)&lt;br&gt;&lt;br&gt;
 Procedural languages&lt;/p&gt;

&lt;h4&gt;
  
  
  Postgres Database limitations
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NTfnOWaq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/1%2A8NLs8AT-X1UzP1_NDscFBg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NTfnOWaq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/1%2A8NLs8AT-X1UzP1_NDscFBg.jpeg" alt="" width="800" height="349"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Limitations&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PostgreSQL terminology&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VxNDim22--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/1%2AI1_Zbr-DiwuyrlgPr2w16g.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VxNDim22--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/800/1%2AI1_Zbr-DiwuyrlgPr2w16g.jpeg" alt="" width="800" height="258"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Terminology&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;PostgreSQL is an enterprise class, open source relational database management system.&lt;/p&gt;

&lt;p&gt;PostgreSQL has a rich history and was created at UC Berkeley. PostgreSQL is flexible, and can scale into the future.&lt;/p&gt;

&lt;p&gt;The PostgreSQL engine adds new features and functionality to appeal to new use cases.&lt;/p&gt;

</description>
      <category>database</category>
      <category>webappdevelopment</category>
      <category>postgres</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Node Awesome Filesystem Magic</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Fri, 16 Oct 2020 12:59:03 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/node-awesome-filesystem-magic-841</link>
      <guid>https://dev.to/rajdeepdas/node-awesome-filesystem-magic-841</guid>
      <description>&lt;h4&gt;
  
  
  Build a simple file watcher👀 without external dependencies or packages from NPM
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--A4LABxVl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2ADfkLzp_6XqwSbABN" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A4LABxVl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2ADfkLzp_6XqwSbABN" alt="" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by Sean Lim on Unsplash&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let’s get started by developing a couple of simple programs that watch files&lt;br&gt;&lt;br&gt;
for changes and read arguments from the command line. Even though they’re&lt;br&gt;&lt;br&gt;
simple toy program, these applications offer insights into Node.js’s event-based architecture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Power of asynchronous programming&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The power of asynchronous coding in Node.js. Taking action whenever a file changes is just plain useful in a number of cases, ranging from automated deployments to running unit tests.&lt;/p&gt;

&lt;p&gt;Our File Watcher 👀 in Action&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**const** fs = require('fs');

**const** filename = process.argv[2];

if(!filename) {
    throw Error('A file must specified');
}

fs.watch(filename, () **=&amp;gt;** console.log(`File ${filename} changed!` ));

console.log(`Now Watching Your Awesome ${filename} for change `);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E_OlI0vk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/767/1%2Ag_VL5XP1Omj6lLLsMy6yng.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E_OlI0vk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/767/1%2Ag_VL5XP1Omj6lLLsMy6yng.png" alt="" width="767" height="96"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;File Watcher In Action&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Great Event Loop ⚡&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To run the program, Node.js does the following:&lt;br&gt;&lt;br&gt;
• It loads the script, running all the way through to the last line, which&lt;br&gt;&lt;br&gt;
produces the Now watching message in the console.&lt;br&gt;&lt;br&gt;
• It sees that there’s more to do because of the call to &lt;em&gt;fs.watch()&lt;/em&gt;.&lt;br&gt;&lt;br&gt;
• It waits for something to happen — namely, for the fs module to observe a&lt;br&gt;&lt;br&gt;
change to the file.&lt;br&gt;&lt;br&gt;
• It executes our callback function when the change is detected.&lt;br&gt;&lt;br&gt;
• It determines that the program still has not finished, and resumes waiting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Node.js Process&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Any unhandled exception thrown in Node.js will halt the process. The exception output shows the offending file and the line number and position of the exception. It’s pretty common (maybe or mayn't be🙄 ) in Node.js development to spawn separate processes as a way of breaking up work, rather than putting everything into one big Node.js program. let’s spawn a process in Node.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spawning a Child Process&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict'
**const** fs = require('fs');
**const** spawn = require('child_process').spawn;
**const** filename = process.argv[2];

if(!filename) {
  throw Error('A file must specified');
}

fs.watch(filename ,() **=&amp;gt;** {
**const** ls = spawn('ls', ['-l', '-h', filename]);
ls.stdout.pipe(process.stdout);

});

console.log(`Now Watching Your Awesome ${filename} for change `);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The object returned by &lt;strong&gt;&lt;em&gt;spawn()&lt;/em&gt;&lt;/strong&gt; is a Child Process. Its &lt;strong&gt;&lt;em&gt;stdin&lt;/em&gt;&lt;/strong&gt; , &lt;strong&gt;&lt;em&gt;stdout&lt;/em&gt;&lt;/strong&gt; , and &lt;strong&gt;stderr&lt;/strong&gt; properties are Streams that can be used to read or write data. We want to send the standard output from the child process directly to our own standard output stream. This is what the &lt;strong&gt;&lt;em&gt;pipe()&lt;/em&gt;&lt;/strong&gt; method does.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3T6fWsDy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/960/1%2ApIp0jpHK3X6lsuzLx392dQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3T6fWsDy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/960/1%2ApIp0jpHK3X6lsuzLx392dQ.png" alt="" width="800" height="88"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The New Child Process In Action&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Capture The Data From Stream or Event Emitter&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EventEmitter&lt;/strong&gt; is a very important class in Node.js. It provides a channel for events to be dispatched and listeners to be notified. Many objects you’ll encounter in Node.js inherit from &lt;strong&gt;EventEmitter&lt;/strong&gt; , like the Streams we saw in the last section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict'

**const** fs = require('fs');
**const** spawn = require('child_process').spawn;
**const** filename = process.argv[2];

if(!filename) {

   throw Error('A file must specified');
}

fs.watch(filename ,() **=&amp;gt;** {

**const** ls = spawn('ls', ['-l', '-h', filename]);

**let** outpt = '';

_// Added event listener like 'data', 'close'_

ls.stdout.on('data', chunk **=&amp;gt;** outpt += chunk);

ls.on('close', () **=&amp;gt;** {

**const** parts = outpt.split(/|s+/);

console.log(parts[0],parts[4],parts[8]);

});

ls.stdout.pipe(process.stdout);

});

console.log(`Now Watching Your Awesome ${filename} for change `);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1YPEwAKj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/962/1%2AZvBD1u5b_oQwXFoBzMh6gw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1YPEwAKj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/962/1%2AZvBD1u5b_oQwXFoBzMh6gw.png" alt="" width="800" height="177"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;EventEmitter Stream in action&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;on()&lt;/em&gt;&lt;/strong&gt; method adds a listener for the specified event type. We listen for data events because we’re interested in data coming out of the stream.&lt;/p&gt;

&lt;p&gt;A Buffer is Node.js’s way of representing binary data.It points to a blob of memory allocated by Node.js’s native core, outside of the JavaScript engine.&lt;/p&gt;

&lt;p&gt;Any time you add a non-string to a string in JavaScript (like we’re doing here&lt;br&gt;&lt;br&gt;
with chunk), the runtime will implicitly call the object’s &lt;strong&gt;&lt;em&gt;toString()&lt;/em&gt;&lt;/strong&gt; method.&lt;br&gt;&lt;br&gt;
For a Buffer, this means copying the content into Node.js’s heap using the default encoding (UTF-8).&lt;/p&gt;

&lt;p&gt;Like Stream, the ChildProcess class extends EventEmitter, so we can add listeners to it, as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TObyx5NT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/548/1%2AhvZ-FNljl46UhmWjSQCr3A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TObyx5NT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/548/1%2AhvZ-FNljl46UhmWjSQCr3A.png" alt="" width="548" height="85"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Child Process&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After a child process has exited and all its streams have been flushed, it emits a close event.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reading and Writing Files In Node.js Asynchronously&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;we wrote a series of Node.js programs that could watch files for changes. Now let’s explore Node.js’s methods for reading and writing files. Along the way we’ll see two common error-handling patterns in Node.js &lt;strong&gt;&lt;em&gt;error&lt;/em&gt;&lt;/strong&gt; events on EventEmitters and &lt;strong&gt;&lt;em&gt;err&lt;/em&gt;&lt;/strong&gt; callback arguments.&lt;/p&gt;

&lt;p&gt;There are a few approaches to reading and writing files in Node. The simplest is to read in or write out the entire file at once. This technique works well for small files. Other approaches read and write by creating Streams or staging content in a  &lt;strong&gt;Buffer&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict';
**const** fs = require('fs');
fs.readFile('target.txt', (err, data) **=&amp;gt;** {

if (err) {
   throw err;
}
console.log(data.toString());
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice how the first parameter to the &lt;strong&gt;&lt;em&gt;readFile()&lt;/em&gt;&lt;/strong&gt; callback handler is &lt;strong&gt;err&lt;/strong&gt;. If &lt;strong&gt;&lt;em&gt;readFile()&lt;/em&gt;&lt;/strong&gt; is successful, then err will be null. Otherwise the err parameter will contain an &lt;strong&gt;Error&lt;/strong&gt; object. This is a common error-reporting pattern in Node.js, especially for built-in modules.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'use strict';
**const** fs = require('fs');

fs.writeFile('target.txt', 'This is file conntent', (err) **=&amp;gt;** {
if (err) {
   throw err;
}
console.log('File saved!');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This program writes &lt;strong&gt;&lt;em&gt;This is file content&lt;/em&gt;&lt;/strong&gt; to target.txt (creating it if it doesn’t exist, or overwriting it if it does). If for any reason the file can’t be written, then the err parameter will contain an Error object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Read and Write Streams&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You create a read stream or a write stream by using &lt;em&gt;fs.createReadStream()&lt;/em&gt; and &lt;em&gt;fs.createWriteStream()&lt;/em&gt;, respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rebuild Cat program in node&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_#!/usr/bin/env node_  
'use strict'
require('fs').createReadStream(process.argv[2]).pipe(process.stdout)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because the first line starts with #!, you can execute this program directly in Unix-like systems. Use &lt;strong&gt;&lt;em&gt;chmod&lt;/em&gt;&lt;/strong&gt; to make it executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ chmod +x cat.js 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, to run it, send the name of the chosen file as an additional argument:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ./cat.js target.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have learned how to watch files for changes and to read and write files. we also learned how to spawn child processes and access command-line arguments. Node.js also support synchronous file access but it’s better not to block event-loop unless you know what you are doing.&lt;/p&gt;

&lt;p&gt;Thank you. Happy Reading 😀😀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://rajdeep-das.github.io"&gt;Software Engineer&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>microservices</category>
      <category>softwaredevelopment</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Short Intro about serverless applications</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Sun, 08 Mar 2020 16:23:38 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/short-intro-about-serverless-applications-5eb</link>
      <guid>https://dev.to/rajdeepdas/short-intro-about-serverless-applications-5eb</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FocmDCtN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2AnST7aiX45xiqc4hL" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FocmDCtN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/1024/0%2AnST7aiX45xiqc4hL" alt="" width="800" height="534"&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/@wocintechchat?utm_source=medium&amp;amp;utm_medium=referral"&gt;Christina @ wocintechchat.com&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is serverless?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Serverless workloads are “event-driven workloads that aren’t concerned with aspects normally handled by server infrastructure.” Concerns like “how many instances to run” and “what operating system to use” are all managed by a Function as a Service platform (or FaaS), leaving developers free to focus on business logic.&lt;/p&gt;

&lt;p&gt;The above definition by the spring.io group.&lt;/p&gt;

&lt;p&gt;Generally when we talk about serverless architecture first things comes to mind is most popular &lt;strong&gt;Function as a service&lt;/strong&gt; ( &lt;strong&gt;FaaS&lt;/strong&gt; ) model on cloud.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What the heck is FaaS?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;According to Wikipedia &lt;strong&gt;&lt;em&gt;Function as a service (FaaS)&lt;/em&gt;&lt;/strong&gt; is a category of cloud computing services that provides a platform allowing customers to develop, run, and manage application functionalities without the complexity of building and maintaining the infrastructure typically associated with developing and launching an app. Building an application following this model is one way of achieving a “serverless” architecture, and is typically used when building microservices applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/AWS_Lambda"&gt;AWS Lambda&lt;/a&gt; was the first FaaS offering by a large public cloud vendor, followed by &lt;a href="https://cloud.google.com/functions/"&gt;Google Cloud Functions&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/Microsoft_Azure"&gt;Microsoft Azure&lt;/a&gt; Functions, &lt;a href="https://en.wikipedia.org/wiki/IBM"&gt;IBM&lt;/a&gt;/&lt;a href="https://en.wikipedia.org/wiki/Apache_Software_Foundation"&gt;Apache&lt;/a&gt;’s &lt;a href="https://en.wikipedia.org/wiki/OpenWhisk"&gt;OpenWhisk&lt;/a&gt; (&lt;a href="https://en.wikipedia.org/wiki/Open_source"&gt;open source&lt;/a&gt;) in 2016 and &lt;a href="https://en.wikipedia.org/wiki/Oracle_Cloud_Platform"&gt;Oracle Cloud&lt;/a&gt; Fn (open source) in 2017.&lt;/p&gt;

&lt;p&gt;Use cases for FaaS are associated with “on-demand” functionality that enables the supporting infrastructure to be powered down and not incurring charges when not in use. Examples include data processing (e.g., batch processing, stream processing, extract-transform-load (ETL)), Internet of things (IoT) services for Internet-connected devices, mobile applications, and web applications.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/1r3vMYywNLk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Let’s looks at a sample code example of firebase cloud function which supports node.js function as services. In the example, we build a REST endpoint with node.js and express framework. &lt;strong&gt;&lt;em&gt;The below code currently in production as a backend service for a mobile app&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/media/7ed20259e5f6f21788941b81ebee8b62/href"&gt;&lt;/a&gt;&lt;a href="https://medium.com/media/7ed20259e5f6f21788941b81ebee8b62/href"&gt;https://medium.com/media/7ed20259e5f6f21788941b81ebee8b62/href&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Serverless characteristics?
&lt;/h3&gt;

&lt;p&gt;Serverless applications have a number of specific characteristics, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Event-driven code execution with triggers&lt;/li&gt;
&lt;li&gt;The platform handles all the starting, stopping, and scaling chores&lt;/li&gt;
&lt;li&gt;Scales to zero, with low to no cost when idle&lt;/li&gt;
&lt;li&gt;Stateless&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P4KGv-zm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/752/1%2ALXu4oxILpYe6QSUM7j7ZOQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4KGv-zm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/752/1%2ALXu4oxILpYe6QSUM7j7ZOQ.jpeg" alt="" width="752" height="791"&gt;&lt;/a&gt;&lt;a href="https://spring.io/serverless"&gt;The Image from spring.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;List of Resources for Serverless platform for getting started&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/lambda/"&gt;https://aws.amazon.com/lambda/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://firebase.google.com/docs/functions"&gt;https://firebase.google.com/docs/functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://spring.io/serverless"&gt;https://spring.io/serverless&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://azure.microsoft.com/en-in/services/functions/"&gt;https://azure.microsoft.com/en-in/services/functions/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thank you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://twitter.com/rajdeepdevs"&gt;Rajdeep Das&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>serverless</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Modern days Identity management for your next project</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Fri, 18 Oct 2019 14:28:26 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/modern-days-identity-management-for-your-next-project-d57</link>
      <guid>https://dev.to/rajdeepdas/modern-days-identity-management-for-your-next-project-d57</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--clfjhzBT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/854/0%2AV9BFj0vo0Iyj41sW" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--clfjhzBT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/854/0%2AV9BFj0vo0Iyj41sW" alt="" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Custom Build vs Paid Identity Management Services&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Identity Management?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Identity management, refers to a service or platform that identifies individuals and controls their access to system resources through user rights and restrictions.Identity management is important for &lt;strong&gt;security&lt;/strong&gt; and increases the &lt;strong&gt;productivity of users&lt;/strong&gt; by implementing a central directory: users don’t need to remember and keep track of several different usernames and passwords.&lt;/p&gt;

&lt;p&gt;According to Wikipedia Identity management, also known as identity and access management, is a framework of policies and technologies for ensuring that the proper people in an enterprise have the appropriate access to technology resources. IdM systems fall under the overarching umbrella of IT security and Data Management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use cases&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Identity management solutions provide benefits for all types of businesses. IAM can also provide distinct and specialized features to serve B2B, B2C, and B2E use cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B2B&lt;/strong&gt; : A business provides federated identity management to another business, such as Trello allowing another business to log into Trello with their enterprise credentials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B2C&lt;/strong&gt; : A business provides social authentication to consumers through Facebook, Google, or other social media identity providers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B2E&lt;/strong&gt; : A business provides single sign-on to its own employees.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Different types of identity management solution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Federated Identity&lt;/strong&gt; : Federated Identity Management is a method of transferring authentication data without violating the same origin policy, generally by using an external authorization server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single Sign On (SSO)&lt;/strong&gt;: SSO is a type of Federated Identity Management. SSO occurs when a user logs into one client and is then signed in to other clients automatically, regardless of differences in platform, technology, or domain. A token or cookie is generated to authenticate the user across domains.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enterprise Federation&lt;/strong&gt; : Enterprise Federation is Federated Identity Management with enterprise connections such as Active Directory, LDAP, ADFS, SAML, Google Apps, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Signs You Need to Move From Custom Build to an Identity Management Solution&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You need a standards-based solution, such as OpenID Connect, SAML, WS-Federation, and/or OAuth&lt;/li&gt;
&lt;li&gt;You have users that authenticate with various identity providers but lack a way to link their accounts.&lt;/li&gt;
&lt;li&gt;You have applications on different domains and require users to log in separately for each.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Your best developers spend their time building and maintaining identity management and authentication instead of building core business applications.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Your company has experienced any type of data breach or you are concerned with a data breach.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here Specifically I will talk about &lt;strong&gt;B2C(Business to Customers)&lt;/strong&gt; Identity Management Use Cases.&lt;/p&gt;

&lt;p&gt;Why we want a 3rd Party identity management Solution for B2C Products specially for Startups,Small to medium business&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your main source of user data comes from directly asking users on forms or surveys. Being able to easily extract third party data about your users would help you better understand your customers and drive more revenue through upsells and targeted marketing.&lt;/li&gt;
&lt;li&gt;If you sell to consumers, you don’t offer an easy 1-click signup option through social identity providers.&lt;/li&gt;
&lt;li&gt;You’ve faced performance concerns as you increased your user base.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Last but not the least as developer i faced this issue of managing own identity management solution really really slow down your core business and product development and also increase the security threats.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;List of popular 3rd party identity management solution&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Auth0[&lt;a href="https://auth0.com/"&gt;https://auth0.com/&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;Okta[&lt;a href="https://www.okta.com/"&gt;https://www.okta.com/&lt;/a&gt;]&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I’m not going to compare which is better both are good and I have used both , you can try this freely for your upcoming projects&lt;/p&gt;

&lt;p&gt;Others Identity Management Solution are&lt;/p&gt;

&lt;h3&gt;
  
  
  Published By
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Originally published at&lt;/em&gt; &lt;a href="https://www.linkedin.com/pulse/modern-days-identity-management-your-next-project-rajdeep-das"&gt;&lt;em&gt;https://www.linkedin.com&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>authentication</category>
      <category>authorization</category>
      <category>webdev</category>
    </item>
    <item>
      <title>SSE(Server-Sent Events) VS WebSocket</title>
      <dc:creator>Rajdeep Das</dc:creator>
      <pubDate>Tue, 20 Aug 2019 15:43:29 +0000</pubDate>
      <link>https://dev.to/rajdeepdas/sseserver-sent-events-vs-websocket-1lnl</link>
      <guid>https://dev.to/rajdeepdas/sseserver-sent-events-vs-websocket-1lnl</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vT-NJWQE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/880/1%2AkFmD_qjKpsg8BqftU0kqtQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vT-NJWQE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn-images-1.medium.com/max/880/1%2AkFmD_qjKpsg8BqftU0kqtQ.jpeg" alt="" width="800" height="550"&gt;&lt;/a&gt;&lt;a href="https://github.com/manucorporat/sse"&gt;&lt;/a&gt;&lt;a href="https://github.com/manucorporat/sse"&gt;https://github.com/manucorporat/sse&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For beginners, both WebSockets and SSEs make use of HTTP connections, although in case of WebSockets a TCP handshake effectively upgrades from HTTP protocol to WebSocket protocol, allowing WebSocket applications to more easily fit into existing infrastructures. However, the main similarity between both is their functionality: both push data from the client to server, a process also known as “server push”. With this in mind, let´s now have a look at some differences between the two before we can talk about best use cases for both technologies.&lt;/p&gt;

&lt;p&gt;Before we get into the differences between both technologies, we should state they’re not competing technologies, nor is one better than the other. The popularity of WebSockets over SSEs can be explained by the fac that WebSockets have received more attention (and appreciation) than SSEs, and it’s a fact that more browsers support it natively than they support SSEs.&lt;/p&gt;

&lt;p&gt;The differences between both technologies are not that big, and if you want to do &lt;strong&gt;“server-push”&lt;/strong&gt; only, both are good choices.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;By far the biggest difference between both technologies is that WebSockets are full-duplex, bidirectional communication between client and server, whereas SSEs are mono-directional.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;SSEs come with a set of features that WebSockets lack by design, such as &lt;strong&gt;automatic reconnection&lt;/strong&gt; , event IDs and sending arbitrary events. On the other hand, WebSockets are able to detect a dropped client connection, whereas SSEs first need to send a message before detecting the same issue. In terms of browser support, both Internet Explorer and Edge do not yet support SSEs, although polyfills that simulate SSE functionality are available to solve this issue.&lt;/p&gt;

&lt;p&gt;Although WebSockets use an initial HTTP connection, this connection is updated after a TCP handshake after which data is sent through the WebSocket protocol. This is a more complex protocol than the SSE protocol. Because they’re &lt;strong&gt;bidirectional&lt;/strong&gt; , WebSocktets require more development effort than SSEs, that only need to &lt;em&gt;send an HTTP message with a specific header&lt;/em&gt;, whereas a WebSocket needs to establish and maintain a &lt;em&gt;TCP socket communication, as well as a listener socket on the server side.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It´s good to know that SSE suffers from a limitation to the maximum number of open connections, which can be specially painful when opening various tabs as the limit is per browser is &lt;strong&gt;six&lt;/strong&gt;. &lt;strong&gt;Only WebSockets can transmit both binary data and UTF-8, whereas SSE is limited to UTF-8.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While WebSockets are more complex and demanding than SSEs, a full-duplex TCP connection makes it useful for a wider range of application scenarios. SSE is a simpler and faster solution, but it isn’t extensible: if your web application requirements were to change, it would need to be refactored using WebSocket. Although WebSocket technology presents more upfront work, it´s a more versatile and extensible framework, so a better option for complex applications that will add new features over time.&lt;/p&gt;

&lt;h3&gt;
  
  
  WS and SSE Best Use Cases
&lt;/h3&gt;

&lt;p&gt;In the end, whether you should be using WebSockets or SSEs depends on your use case. As stated before, SSEs cannot provide bidirectional client-server communication as opposed to WebSockets. &lt;strong&gt;Use cases that require such communication are real-time multi-player games and messaging and chat apps.&lt;/strong&gt;  &lt;strong&gt;When there´s no need for sending data from a client, SSEs might be a better option than WebSockets.&lt;/strong&gt; Examples of such use cases are &lt;strong&gt;status updates&lt;/strong&gt; , &lt;strong&gt;news feeds&lt;/strong&gt; and other automated data push mechanisms.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Server Sence( A Upcoming Project by RajdeepDev’s) Use SSE
&lt;/h3&gt;

&lt;p&gt;ServerSence is RealTime Server , Web App monitoring Solution with instant alert for server or Web app failure.You don’t have to develop or maintain a monitoring solution for your appwe take care of that, so you can deliver amazing User Experience to client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server Sence&lt;/strong&gt; Dashboard Use &lt;strong&gt;SSEs&lt;/strong&gt; for realtime visulization of Server and Web App Status and Sending Realtime Alert.(For more details contact &lt;strong&gt;&lt;a href="mailto:rajdeepdas.india@gmail.com"&gt;rajdeepdas.india@gmail.com&lt;/a&gt;&lt;/strong&gt; , if you want to be part of that project).&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this post we compared WebSockets and SSEs. We discussed the differences and similarities between the two technologies. While both can be used for “server push”, there are many subtle differences between the two. Because WebSockets have received more attention from developers and bloggers, &lt;strong&gt;SSEs are lesser-known but no less potent&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Published By
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Originally published at&lt;/em&gt; &lt;a href="https://www.linkedin.com/pulse/sseserver-sent-events-vs-websocket-rajdeep-das"&gt;&lt;em&gt;https://www.linkedin.com&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>websocket</category>
      <category>webdev</category>
      <category>realtimeapplications</category>
    </item>
  </channel>
</rss>
