<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mayank Gupta on Medium]]></title>
        <description><![CDATA[Stories by Mayank Gupta on Medium]]></description>
        <link>https://medium.com/@mayankgupta1338?source=rss-ad1d5844950f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XEEJFUp5Yffv5ysJPhOybw.jpeg</url>
            <title>Stories by Mayank Gupta on Medium</title>
            <link>https://medium.com/@mayankgupta1338?source=rss-ad1d5844950f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:13:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mayankgupta1338/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Your Mac Might Be Holding Your Passwords in Plain Sight. Here’s How to Check. · Tidzy]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://mayankgupta1338.medium.com/your-mac-might-be-holding-your-passwords-in-plain-sight-heres-how-to-check-tidzy-efbaf69d6b29?source=rss-ad1d5844950f------2"><img src="https://cdn-images-1.medium.com/max/1800/0*rMq6EJA3q71CQ5fD.jpg" width="1800"></a></p><p class="medium-feed-snippet">Screenshots of passwords, ID scans and card photos pile up where you never look. Here&#x2019;s how to find them and what to do with each.</p><p class="medium-feed-link"><a href="https://mayankgupta1338.medium.com/your-mac-might-be-holding-your-passwords-in-plain-sight-heres-how-to-check-tidzy-efbaf69d6b29?source=rss-ad1d5844950f------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://mayankgupta1338.medium.com/your-mac-might-be-holding-your-passwords-in-plain-sight-heres-how-to-check-tidzy-efbaf69d6b29?source=rss-ad1d5844950f------2</link>
            <guid isPermaLink="false">https://medium.com/p/efbaf69d6b29</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[apple-privacy]]></category>
            <category><![CDATA[mac-cleaner]]></category>
            <dc:creator><![CDATA[Mayank Gupta]]></dc:creator>
            <pubDate>Sat, 17 Oct 2026 08:57:35 GMT</pubDate>
            <atom:updated>2026-10-17T08:57:35.840Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Building Tidzy: 7 Problems I Solved to Make a Mac App People Keep · Tidzy]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://mayankgupta1338.medium.com/building-tidzy-7-problems-i-solved-to-make-a-mac-app-people-keep-tidzy-03368cbeaf52?source=rss-ad1d5844950f------2"><img src="https://cdn-images-1.medium.com/max/2000/0*1fyF5uYzKyx1gZCH.jpg" width="2000"></a></p><p class="medium-feed-snippet">Every Mac fills up with files nobody can find. These are the problems I hit building an app to fix that, and how I solved each one.</p><p class="medium-feed-link"><a href="https://mayankgupta1338.medium.com/building-tidzy-7-problems-i-solved-to-make-a-mac-app-people-keep-tidzy-03368cbeaf52?source=rss-ad1d5844950f------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://mayankgupta1338.medium.com/building-tidzy-7-problems-i-solved-to-make-a-mac-app-people-keep-tidzy-03368cbeaf52?source=rss-ad1d5844950f------2</link>
            <guid isPermaLink="false">https://medium.com/p/03368cbeaf52</guid>
            <category><![CDATA[showdev]]></category>
            <category><![CDATA[build-in-public]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Mayank Gupta]]></dc:creator>
            <pubDate>Sat, 17 Oct 2026 08:55:04 GMT</pubDate>
            <atom:updated>2026-10-17T08:55:04.400Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Stop Retyping Screenshots: How to Copy Text From Any Image on Your Mac · Tidzy]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://mayankgupta1338.medium.com/stop-retyping-screenshots-how-to-copy-text-from-any-image-on-your-mac-tidzy-3435898f6af4?source=rss-ad1d5844950f------2"><img src="https://cdn-images-1.medium.com/max/640/0*b_3u8osVeBpVPg8B.gif" width="640"></a></p><p class="medium-feed-snippet">The text is right there in the image, and you still end up typing it out. Here&#x2019;s the one-drag fix.</p><p class="medium-feed-link"><a href="https://mayankgupta1338.medium.com/stop-retyping-screenshots-how-to-copy-text-from-any-image-on-your-mac-tidzy-3435898f6af4?source=rss-ad1d5844950f------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://mayankgupta1338.medium.com/stop-retyping-screenshots-how-to-copy-text-from-any-image-on-your-mac-tidzy-3435898f6af4?source=rss-ad1d5844950f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3435898f6af4</guid>
            <category><![CDATA[read-from-image]]></category>
            <category><![CDATA[build-in-public]]></category>
            <category><![CDATA[mac-apps]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[read-from-file]]></category>
            <dc:creator><![CDATA[Mayank Gupta]]></dc:creator>
            <pubDate>Sat, 17 Oct 2026 08:53:19 GMT</pubDate>
            <atom:updated>2026-10-17T08:53:19.633Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Upstream vs Downstream in Microservices]]></title>
            <link>https://mayankgupta1338.medium.com/upstream-vs-downstream-in-microservices-aa287d89d258?source=rss-ad1d5844950f------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa287d89d258</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[upstream-downstream]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[dataflow]]></category>
            <dc:creator><![CDATA[Mayank Gupta]]></dc:creator>
            <pubDate>Mon, 29 Sep 2025 06:32:44 GMT</pubDate>
            <atom:updated>2025-09-29T06:33:23.509Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BgXBx1ysslA3auFLFObNvg.jpeg" /></figure><p>Many of us have heard a lot about upstream and downstream services when working with microservices or in general client/server communication, especially where multiple services or even external ones are involved. So, let’s understand this in very simple language.</p><h3><strong>What does upstream service mean?</strong></h3><p>A service or an application is called <strong>upstream</strong> if it provides any sort of data to other services. For example, think of your application backend server as the primary data source. If other services or clients connect to it, then the backend service is called an <strong>upstream service</strong> since it provides data or functionality to others.</p><p>Think of upstream service as <strong>“provider”</strong></p><pre>         ┌──────────────────────┐<br>         │   Upstream Service   │<br>         │  (Data / API Source) │<br>         └──────────┬───────────┘<br>                    │<br>                    ▼<br>         ┌──────────────────────┐<br>         │   Downstream Service │<br>         │  (Consumes the Data) │<br>         └──────────────────────┘</pre><p>In this flow, the <strong>top box is upstream</strong> because it supplies data to the service below.</p><h3><strong>What does downstream service mean?</strong></h3><p>A service or an application that consumes data from other services is called a <strong>downstream</strong> service. It acts as a consumer. For example, the front-end application, when it connects to the backend application or an API server, is called a <strong>downstream service</strong> since it consumes data from the backend app.</p><p>Think of downstream service as <strong>“consumer”</strong></p><pre>         ┌──────────────────────┐<br>         │   Upstream Service   │<br>         │  (Provides Orders)   │<br>         └──────────┬───────────┘<br>                    │<br>                    ▼<br>         ┌──────────────────────┐<br>         │ Downstream Service   │<br>         │  (Consumes Orders)   │<br>         └──────────────────────┘</pre><p>In this flow, the <strong>bottom box is downstream</strong> since it depends on the upstream.</p><p><strong><em>So it all depends on the direction of the data or the request flow that will identify if the service is downstream or upstream.</em></strong></p><h3>Example</h3><p>Let’s understand more with a real-world example.<br>Suppose we have three services in an e-commerce platform:</p><ul><li><strong>Payment service</strong> — Handles payment processing while placing orders.</li><li><strong>Order service</strong> — Handles order creation and other order-related operations.</li><li><strong>Notification service</strong> — Handles tasks related to sending notifications to users.</li></ul><p><strong>Request Flow:</strong></p><p>When a customer places an order:<br> <strong>Order Service → calls Payment Service → calls Notification Service.</strong></p><p>Here:</p><ul><li>For the Payment service: <br>– <strong>Upstream service</strong> will be “Order service”, since it sends a request to the payment service.<br>– <strong>Downstream service</strong> will be the Notification service, since the payment service calls it to send a notification based on the payment status.</li><li>For the Order service<br>– It only has a <strong>downstream dependency</strong> (Payment service).</li><li>For the Notification service<br>– Downstream to Payment (receives notification requests).</li></ul><pre>   ┌──────────────────────┐<br>   │    Order Service     │<br>   │ (Upstream to Payment │<br>   │   Receives request   │<br>   │   from Front-end)    │<br>   └──────────┬───────────┘<br>              │<br>              ▼<br>   ┌──────────────────────┐<br>   │   Payment Service    │<br>   │ (Downstream to Order │<br>   │  Upstream to Notify) │<br>   └──────────┬───────────┘<br>              │<br>              ▼<br>   ┌──────────────────────┐<br>   │ Notification Service │<br>   │ (Downstream: consumes│<br>   │   from Payment)      │<br>   └──────────────────────┘</pre><h3>Key Notes on Dependencies</h3><ul><li><strong>Direction matters</strong>: Upstream provides, downstream consumes.</li><li><strong>Failure:</strong> If an upstream service fails, all its downstream services are affected.</li><li><strong>Compatibility</strong>: Upstream services must avoid breaking changes, as they directly impact multiple downstream systems.</li><li><strong>Resilience</strong>: Downstream services should handle failures gracefully with retries, fallbacks, or circuit breakers.</li></ul><p><em>Every service can be upstream for one and downstream for another, it all depends on the direction of the data or request flow.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa287d89d258" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Javascript Event Loop]]></title>
            <link>https://mayankgupta1338.medium.com/understanding-the-javascript-event-loop-9dd4278ad8df?source=rss-ad1d5844950f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9dd4278ad8df</guid>
            <category><![CDATA[asynchronous-programming]]></category>
            <category><![CDATA[event-loop]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-event-loop]]></category>
            <dc:creator><![CDATA[Mayank Gupta]]></dc:creator>
            <pubDate>Fri, 29 Nov 2024 09:10:23 GMT</pubDate>
            <atom:updated>2024-11-29T09:10:23.499Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKRRfQFX1mc8qPXlhzXYBQ.jpeg" /></figure><p>Some common questions around the Event loop</p><ul><li><strong><em>If JavaScript is single-threaded how does the event loop handle asynchronous tasks?</em></strong></li><li><strong><em>Does it run on the same main thread?</em></strong></li><li><strong><em>Does it block synchronous code when processing async tasks?</em></strong></li></ul><h3><strong>What is an Event Loop?</strong></h3><p>The Event loop is a mechanism that enables JavaScript to handle asynchronous tasks without blocking the execution of synchronous code. To simplify in layman&#39;s language, it’s like an invisible worker constantly checking for tasks that need to be executed. Imagine it as the manager of a busy restaurant, organizing orders and ensuring every task is completed in a timely manner.</p><h3>Why Does JavaScript Need the Event Loop?</h3><p>Javascript is single-threaded meaning it can execute only one task at a time. While this works well for simple synchronous operations, asynchronous tasks like API requests or web APIs (`setTimeout`) could freeze the entire application if not handled properly.</p><p>For example, imagine a factory with just one worker — this is JavaScript being single-threaded. The worker can only work on one task at a time, but with the event loop, the worker is able to handle multiple tasks efficiently by taking breaks to check for new tasks while completing the ongoing ones.</p><p>Let’s see with an example:</p><pre>function TaskOne() {<br>   console.log(&quot;Performing Task One&quot;);<br>}<br><br>function TaskTwo() {<br>   console.log(&quot;Performing Task Two&quot;);<br>}<br><br>function EndShift() {<br>   console.log(&quot;Worker Shift Ends&quot;)<br>}<br><br><br>// Calling or Execution<br>TaskOne();<br>TaskTwo();<br>EndShift();<br><br>// Output<br>- Performing Task One<br>- Performing Task Two<br>- Worker Shift Ends</pre><p>In this synchronous code, tasks are executed sequentially. Easy to understand, right? But what happens when asynchronous operations come into play? Let’s see an example</p><h3>Asynchronous Code and the Event Loop</h3><p>Let’s add some async operations to the execution</p><pre>function TaskOne() {<br>   console.log(&quot;Performing Task One&quot;);<br>}<br><br>function AsyncTaskOne() {<br>  setTimeout(() =&gt; {<br>       console.log(&#39;Moving to Home&#39;);<br>  }, 2000)<br>}<br><br>function EndShift() {<br>   console.log(&quot;Worker Shift Ends&quot;)<br>}<br><br>// Execution<br>TaskOne();<br>AsyncTaskOne();<br>EndShift();<br><br>// Output<br>- Performing Task One<br>- Worker Shift Ends<br>- Moving to Home</pre><p>In the output, notice that Moving to Home is logged last, even though asyncTaskOne was called before endShift. This behavior is where the event loop shines. Here’s what happens behind the scenes:</p><ol><li>The synchronous code (taskOne and endShift) runs on the main thread.</li><li>The asynchronous code setTimeout callback is handed off to the Web APIs (part of the browser environment) which manages the delay in the background.</li><li>Once the timer completes the callback (console.log(&quot;Moving to Home&quot;)) is placed in the task queue.</li><li>The event loop checks for the call stack, waits for it to empty, and once it’s empty, it will execute the callback function.</li></ol><h3>What Happens if There is No Event Loop?</h3><p>Imagine your browser trying to download a large file without the event loop. In such a scenario, it will end up blocking the main thread if there is any long-running async operation which leads to a frozen state in browsers.</p><pre>function clickButton1() {<br>  console.log(&#39;User Clicked Button 1&#39;);<br>}<br><br>function fetchWeatherInfo() {<br>  // Async operation<br>  setTimeOut(() =&gt; {<br>    console.log(&#39;Fetching weather information&#39;);<br>  }, 6000)<br>}<br><br>function clickButton2() {<br>  console.log(&#39;User Clicked Button 2&#39;);<br>}<br><br>clickButton1();<br>fetchWeatherInfo();<br>clickButton2();</pre><p>In this example without the event loop, the browser would freeze until fetchWeatherInfofinished. The result? You couldn’t click anything, scroll, or do anything else.</p><h3>Does Asynchronous Code Run on a Separate Thread?</h3><p>Here’s a common question, if async tasks don’t block the main thread, are they running on a different thread? The answer is <strong>no</strong>.</p><p>Even though asynchronous operations like setTimeout or API requests may seem to run independently, <strong><em>they don&#39;t get their own thread.</em></strong> JavaScript is single-threaded, but web APIs (provided by browsers or NodeJS) handle tasks asynchronously in the background. Once these tasks finish, their callbacks are placed into the task queue <em>which is processed by the event loop.</em></p><ul><li>When you call a function setTimeout or make an API request, the heavy lifting is handed off to Web APIs (provided by the browser or NodeJS).</li><li>These APIs handle the task in the background and notify or callback JavaScript when it’s done by placing a callback in the task queue.</li><li>The event loop then picks up these callbacks and executes them on the main thread, one at a time, ensuring the single-threaded nature of JavaScript is preserved.</li></ul><p><strong>Let’s understand some key Components of Event Loop</strong></p><p>To understand the event loop in action, you need to know about three key components:</p><p><strong>Call Stack</strong></p><p>The call stack is where JavaScript keeps track of function calls and their execution. Think of the call stack as JavaScript’s to-do list. It tracks what code is currently running and ensures that JavaScript executes functions in the correct order.</p><pre>function TaskOne(){<br>   console.log(&#39;Executing Task 1&#39;);<br>}<br><br>function TaskTwo(){<br>   console.log(&#39;Executing Task 2&#39;)<br>}<br><br>// Stack Look like this<br>// 1 - Push to stack - TaskOne()<br>// 2 - console.log(&#39;Executing Task 1&#39;);<br>// 3 - Push to stack - TaskTwo()<br>// 4 - console.log(&#39;Executing Task 2&#39;)<br>// 5 - Empty stack </pre><p><strong>Callback Queue (Task Queue)</strong></p><p>The task queue holds tasks (like setTimeout callbacks, DOM events, AJAX requests) that are ready to be executed. Once the call stack is clear, the event loop moves these tasks from the callback queue to the call stack.</p><pre>console.log(&#39;Starting&#39;); // 1<br><br>setTimeout(() =&gt; {<br>    console.log(&#39;Timeout 1&#39;); // 4<br>}, 0);<br><br>setTimeout(() =&gt; {<br>    console.log(&#39;Timeout 2&#39;); // 5<br>}, 0);<br><br>console.log(&#39;Ending&#39;); <br><br>// Ouput<br>// 1 - Starting<br>// 2 - Ending<br>// 3 - Timeout 1<br>// 4 - Timeout 2</pre><p>Despite setting both timeouts to 0 milliseconds, the output shows that the timeouts are added to the task queue and are executed after all synchronous code is done.</p><ul><li>A setTimeout callback is added to the task queue after the timer expires.</li><li>The event loop moves it to the call stack when no other code is running.</li></ul><p><strong>Microtask Queue</strong></p><p>The microtask queue is a special high-priority queue for tasks like Promises or MutationObserver callbacks.</p><p><strong><em>Think of this as the “VIP line” — these tasks jump ahead of the callback queue.</em></strong></p><ul><li>Promise callbacks (.then, .catch, .finally)</li><li>process.nextTick() (in NodeJS)</li></ul><pre>console.log(&quot;Starting&quot;);<br><br>setTimeout(() =&gt; {<br>  console.log(&quot;Task Queue&quot;);<br>}, 0);<br><br>Promise.resolve().then(() =&gt; {<br>  console.log(&quot;Microtask Queue&quot;);<br>});<br><br>console.log(&quot;Ending&quot;);<br><br>// Output<br>// 1 - Starting<br>// 2 - Ending<br>// 3 - Microtask Queue<br>// 4 - Task Queue</pre><p>The event loop is like a traffic controller that coordinates everything:</p><ol><li>It checks if the call stack is empty.</li><li>If the stack is empty, it processes all tasks in the microtask queue.</li><li>Then it picks up tasks from the task queue (one at a time) and executes them.</li></ol><p>This ensures tasks are executed in a smooth non-blocking fashion. Without the Event Loop, your JavaScript would be stuck waiting for every time-consuming operation.</p><h3>Conclusion</h3><p>Understanding these concepts will help you write better asynchronous code and debug applications much better and more effectively. The event loop is the secret behind JavaScript&#39;s ability to handle async tasks while staying <strong><em>single-threaded.</em></strong></p><blockquote>Now when someone asks you “How does JavaScript handle multiple tasks with just one thread? you can explain it with confidence!</blockquote><p>Thanks for reading! Feel free to share your thoughts or questions in the comments below! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9dd4278ad8df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate AWS-lambda deployment using Github actions for NodeJS/Typescript applications.]]></title>
            <link>https://mayankgupta1338.medium.com/automate-aws-lambda-deployment-using-github-actions-for-nodejs-typescript-applications-4b75c7c17e02?source=rss-ad1d5844950f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b75c7c17e02</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Mayank Gupta]]></dc:creator>
            <pubDate>Tue, 04 Jan 2022 13:01:37 GMT</pubDate>
            <atom:updated>2022-01-20T17:36:27.184Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*YcFmahlLvOPyjfNtw1GkbQ.png" /></figure><p>In this tutorial, we will go through how to automate <strong>AWS-lambda </strong>deployment using <strong>Github actions </strong>for NodeJS/Typescript applications with serverless<strong>. </strong>I will try to explain in the simplest form.</p><p><em>Before diving into the tutorial let’s first understand what we mean by Github actions and AWS-lambda</em></p><p><strong>What is Github action?</strong></p><p>Github action is the type of CI/CD (<strong>Continuous Integration and Continuous Delivery</strong>) platform which helps to automate the deployment, build and test process. It allows creating workflows for example if you need to push your front-end application code to AWS s3 or any other storage services on merging code to master or the main branch you can easily achieve it. Apart from it you can perform code builds, code compiling, code packaging, etc.</p><p><strong>What is AWS-Lambda?</strong></p><p>AWS Lambda is <strong><em>serverless</em></strong> compute service which we also call a function-based compute service that benefits in saving time and effort of managing infrastructure, with lambda you don’t need to worry about managing infrastructure or scaling instances and managing resources. It is all handled by lambda automatically, you just need to focus on writing bug-free code.😛</p><p>Let’s get started now 🏇.</p><p>Create an empty directory .github/workflows in your project root folder and create deploy.yml file.</p><pre>name: lambda-deployment-with-github-action-test<br><br>on: <br>  push:<br>    branches:<br>        main # You can use any of your root or master branch name<br>  <br>jobs:<br>  lambda-deploy:<br>  	runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout to repo<br>        uses: actions/checkout@v2<br><br>      - name: Setup node environment<br>        uses: actions/setup-node@v1<br>        with:<br>          node-version: &#39;14.x&#39;<br>          <br>      - name: Install serverless globally<br>        run: npm install -g serverless<br>      <br>      - name: Configure serverless authentication<br>        run: sls config credentials --provider aws --key ${{ secrets.AWS_ACCESS_KEY_ID }} --secret ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br><br>      - name: Install npm dependencies<br>        run: npm ci<br>     <br>      - name: Deploy lambda function<br>        run: sls deploy</pre><p>Let me explain the workflow and all the variables used in the above YAML configuration.</p><ol><li><strong><em>name</em></strong> — Used for naming workflows, in our case it’s lambda-deployment-with-github-action-test .</li><li><strong><em>on — </em></strong>Name of the Github event that triggers workflows, in our case, the event is push . Here, the workflow will start as soon as you merge code in the listed branch which can be main or master branch.</li><li><strong><em>jobs</em></strong> — This is the part where we specify what action we want to do and it can contain multiple jobs as well. In our case, we are using only a single job that triggers lambda deployment actions. The job runs in a runner environment, In our case, we are using, basically, this is the type of machine to run the job.</li><li><strong><em>steps — </em></strong>This is where we define whats steps to take during the job</li></ol><p>Here is what individual steps mean in the above workflow</p><p>Step 1: Used to <strong>check-out a repository</strong></p><pre>- name: Checkout to repo<br>  uses: actions/checkout@v2</pre><p>Step 2: Used to setup up server with <strong>NodeJS </strong>environment and also you can specify the Nodejs version, in our case, we are using 14.x</p><pre>- name: Setup node environment<br>  uses: actions/setup-node@v1<br>  with:<br>     node-version: &#39;14.x&#39;</pre><p>Step 3: We are using a <a href="https://www.npmjs.com/package/serverless"><strong><em>serverless</em></strong></a> package for deploying to AWS lambda. Setup serverless by installing serverless package globally.</p><pre>- name: Install serverless globally<br>  run: npm install -g serverless</pre><p>Step 4: Configure serverless authentication</p><pre>name: Configure serverless authentication<br> run: sls config credentials --provider aws --key ${{ secrets.AWS_ACCESS_KEY_ID }} --secret ${{ s</pre><p><em>Here I am using the secret variables from Github’s repository secret manager. You can access it by navigating in </em><em>Repository -&gt; Setting -&gt; Secrets and can add secrets and access them in workflows by using </em><em>secrets.{secret_variable_name }`</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*7Z5CCF__ikldB9pS.png" /></figure><p>Step 5: Install project dependencies. Here npm ci is used to make sure to do a clean installation of dependencies and it is also much faster than normal installation and recommended in cases of automated deployments.</p><pre>- name: Install npm dependencies<br>  run: npm ci</pre><p>Step 6: Trigger the serverless deploy command. Using this step we are telling serverless to deploy the package, here serverless automatically handles packaging your application code into a zip file and uploading it to lambda.</p><pre>- name: Deploy lambda functions<br>    run: sls deploy</pre><p>You can mention different stages for your API gateway using stage argument. For e.g sls deploy --stage staging for deploying as staging deployment.</p><p>After the job is completed you can navigate to the AWS lambda to access the application URL in API Gateway.</p><p>Boom, You have successfully automated the NodeJS application deployment with lambda using Github action 🚀😎.</p><p><strong>References:</strong></p><ul><li>Serverless: <a href="https://www.serverless.com/">https://www.serverless.com/</a></li><li>Serverless npm package: <a href="https://www.npmjs.com/package/serverless">https://www.npmjs.com/package/serverless</a></li><li>Github actions: <a href="https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions">https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions</a></li></ul><p><em>Feel free to leave comments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b75c7c17e02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Node JS / Express JS: PayUmoney Payment Integration]]></title>
            <link>https://mayankgupta1338.medium.com/node-js-express-js-payumoney-payment-integration-32d3058c714?source=rss-ad1d5844950f------2</link>
            <guid isPermaLink="false">https://medium.com/p/32d3058c714</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Mayank Gupta]]></dc:creator>
            <pubDate>Mon, 11 Mar 2019 17:56:14 GMT</pubDate>
            <atom:updated>2019-03-12T06:10:11.612Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*MKix5VmezKo1KaWt" /><figcaption>Well, Looking Great…</figcaption></figure><p>Well, We have to build a Web app in Node JS/Express JS, Mongo as DBMS and Ejs as template engine. In the app, We have to integrate Payment gateway so we choose payumoney but struggled in implementing it as the docs were not up to the mark and weren’t clear, so by researching and referring hectic docs it was successfully implemented , So I thought why not get hands dirty on my first medium article and not let others struggle.</p><p>To start with integration, first, you need to have an active <a href="https://www.payumoney.com/">payumoney </a>acccount and you will be provided with Merchant Key and Salt once successfully created account and verified all the details required.</p><p><strong>Note: </strong>Your account may take 2–3 working days for verification.</p><p>Payumoney has two types of checkout <em>One is Bolt and another one is Redirect</em>, but we will gonna focus on Redirect Checkout. Below is a screenshot of how it works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*qsRiHWsS7iJwzl373aBCfw.gif" /><figcaption>Payumoney Redirect checkout</figcaption></figure><p>Here, The most important part where mostly developers face problems is generating hash.</p><p><strong>Generating Hash:</strong></p><pre><em>#Hash Sequence<br>hashSequence =<br>key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||salt</em></pre><p>Above shown is the way of generating a hash. Here the parameters are to be hashed in the following sequence by using “|” after each parameter and provide all the details mentioned above. Here udf1, udf2 … are user-defined fields and these are optional and if you don’t use them you must replace it with empty spaces and use the above exact sequence.</p><pre>hashString = &#39;YOUR_MERCHANT_KEY&#39; <br> + &#39;|&#39; + txnid <br> + &#39;|&#39; + amount <br> + &#39;|&#39; + productinfo <br> + &#39;|&#39; + firstname <br> + &#39;|&#39; + email <br> + &#39;|&#39; + &#39;||||||||||&#39; <br> + &#39;YOUR_MERCHANT_SALT&#39;;</pre><p>Once hashstring is generated in proper sequence, now we need to hash it Using ‘SHA-512’ to generate final hashed value. Here, we will be using <strong><em>‘jssha’</em></strong> npm module for hashing it.</p><p><strong><em>Install Module(jssha)</em></strong>:</p><pre>npm install jssha --save</pre><pre>const sha = new jsSHA(&#39;SHA-512&#39;, &quot;TEXT&quot;);</pre><p>Then pass hashstring in sha update function.</p><pre>sha.update(hashString);</pre><p>Now store hashed value:</p><pre>const hash = sha.getHash(&quot;HEX&quot;);</pre><p>After generating hashString, its time to use it in API. Here We will create POST route. Here express router is used to make a call to API. Payumoney provides testing credentials for implementing and testing purpose.</p><p><strong><em>Testing URL:</em></strong></p><pre><a href="https://sandboxsecure.payu.in/_payment%27">https://sandboxsecure.payu.in/_payment</a></pre><p>After switching to a production environment, remember to change it to production URL</p><p><strong><em>Production URL:</em></strong></p><pre><a href="https://secure.payu.in/_payment">https://secure.payu.in/_payment</a></pre><p><strong>API:</strong></p><pre>const router = express.Router();</pre><pre><em>//We are using request for making an HTTP/HTTPS call to payumoney server</em></pre><pre>const request = require(&#39;request&#39;);</pre><pre>router.post(&#39;/payment_gateway/payumoney&#39;, (req, res) =&gt; {</pre><pre>req.body.txnid = <em>//Here pass txnid and it should be different <br> on every call</em></pre><pre>req.body.email = req.user.email;</pre><pre>req.body.firstname = req.user.firstname;</pre><pre><em>//Here save all the details in pay object <br> const pay = req.body;</em></pre><pre>const hashString = <strong>&#39;YOUR_MERCHANT_KEY&#39;</strong> <em>//</em><strong><em>store in in different file</em></strong><br> + &#39;|&#39; + pay.txnid<br> + &#39;|&#39; + pay.amount <br> + &#39;|&#39; + pay.productinfo <br> + &#39;|&#39; + pay.firstname <br> + &#39;|&#39; + pay.email <br> + &#39;|&#39; + &#39;||||||||||&#39;<br> + <strong>&#39;YOUR_MERCHANT_SALT&#39;</strong> <em>//</em><strong><em>store in in different file</em></strong></pre><pre>const sha = new jsSHA(&#39;SHA-512&#39;, &quot;TEXT&quot;);</pre><pre>sha.update(hashString);</pre><pre><em>//Getting hashed value from </em><strong><em>sha module</em></strong><br> const hash = sha.getHash(&quot;HEX&quot;);<br> <br> <em>//We have to additionally pass merchant key to API</em><br> so remember to include it.</pre><pre>pay.key = <strong>&#39;YOUR_MERCHANT_KEY&#39;</strong> //<strong>store in in different file</strong>;<br> pay.surl = &#39;<strong>PROVIDE SUCCESS URL ROUTE</strong>&#39;;<br> pay.furl = &#39;<strong>PROVIDE FAILRE URL ROUTE&#39;</strong>;<br> pay.hash = hash;</pre><pre><em>//Making an HTTP/HTTPS call with request</em></pre><pre>request.post({<br> headers: {<br> &#39;Accept&#39;: &#39;application/json&#39;,<br> &#39;Content-Type&#39;: &#39;application/json&#39;<br> },<br> url: &#39;<a href="https://sandboxsecure.payu.in/_payment%27">https://sandboxsecure.payu.in/_payment&#39;</a>, <strong><em>//Testing url</em></strong><br> form: pay<br> }, function (error, httpRes, body) {</pre><pre>if (error) <br> res.send(<br> {status: false, <br> message:error.toString()<br> }<br> );</pre><pre>if (httpRes.statusCode === 200) {<br> res.send(body);<br> } else if (httpRes.statusCode &gt;= 300 &amp;&amp; <br> httpRes.statusCode &lt;= 400) {<br> res.redirect(httpRes.headers.location.toString());<br> }<br> })<br>});</pre><p>After calling an API to above route Payumoney will return transaction data. There will be two transaction status fail and transaction success, as we had already provided [surl, furl] which means success URL and failure URL. If it fails it will redirect and send the transaction status to failure URL and if it’s a success then it will redirect and send the status to success URL, So remember to include SURL and FURL.</p><p>Now implement POST API for success and fail URL</p><p><strong>Payment Success URL:</strong></p><pre>route.post(&#39;/payment/success&#39;, (req, res) =&gt; {</pre><pre><em>//Payumoney will send Success Transaction data to req body. <br> Based on the response Implement UI as per you want</em><br> res.send(req.body);</pre><pre>})</pre><p><strong>Payment Failure URL:</strong></p><pre>route.post(&#39;/payment/fail&#39;, (req, res) =&gt; {</pre><pre><em>//Payumoney will send Fail Transaction data to req body. <br> Based on the response Implement UI as per you want</em><br> res.send(req.body);</pre><pre>})</pre><p>For Client-Side, EJS is used as a Template Engine</p><p>Simply install EJS with npm command and set it as default engine for rendering.</p><pre>npm i ejs --save</pre><pre>const app = express() //I guess you know the remaining process</pre><pre>app.set(&#39;view engine&#39;, &#39;ejs&#39;);</pre><p>Now we will call API from front-end, so let’s start</p><p><em>Do remember you don’t need to send </em><strong><em>KEY, SALT &amp; txnid</em></strong><em> from Client-side for security reasons.</em></p><p>Make an EJS file e.g (payment.ejs) and make sure to include a service provider</p><pre>&lt;form action=&quot;payment_gateway/payumoney&quot; method=&quot;POST&quot;&gt;</pre><pre>&lt;input class=&quot;amount&quot; type=&quot;hidden&quot; name=&quot;amount&quot; value=&quot;&quot;/&gt;</pre><pre>&lt;input class=&quot;con&quot; type=&quot;hidden&quot; name=&quot;phone&quot; value=&quot;&quot; /&gt;</pre><pre>&lt;input type=&quot;hidden&quot; name=&quot;service_provider&quot; <br> value=&quot;payu_paisa&quot;/&gt;</pre><pre>&lt;input type=&quot;hidden&quot; class=&quot;product&quot; name=&quot;productinfo&quot; <br> value=&quot;educational purpose&quot;/&gt;<br> <br> &lt;input type=&quot;submit&quot; value=&quot;Pay&quot;/&gt;</pre><pre>&lt;/form&gt;</pre><p>Provide all the details mentioned above from client-side to API based on the response implement UI as per yourself.</p><p>Boom, you have successfully implemented payment gateway in your application.</p><p><em>Guys, It’s my first medium post, Hope you like it. So enjoy Paying !!.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32d3058c714" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>