<?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 Inayat Ullah on Medium]]></title>
        <description><![CDATA[Stories by Inayat Ullah on Medium]]></description>
        <link>https://medium.com/@inayatu?source=rss-1930c56dbf84------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*HsRQcbzpFyxe6nVP</url>
            <title>Stories by Inayat Ullah on Medium</title>
            <link>https://medium.com/@inayatu?source=rss-1930c56dbf84------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 06:20:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@inayatu/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[Simple Queue In Node.js using Redis Server and Bull Package]]></title>
            <link>https://inayatu.medium.com/simple-queue-in-node-js-using-redis-server-and-bull-package-5beeb2db9668?source=rss-1930c56dbf84------2</link>
            <guid isPermaLink="false">https://medium.com/p/5beeb2db9668</guid>
            <category><![CDATA[bull-queues]]></category>
            <category><![CDATA[job-scheduling]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[task-scheduler]]></category>
            <category><![CDATA[queue]]></category>
            <dc:creator><![CDATA[Inayat Ullah]]></dc:creator>
            <pubDate>Tue, 17 Oct 2023 11:18:49 GMT</pubDate>
            <atom:updated>2023-10-17T11:18:49.128Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PFHI-B-yZlalNDthY7-b9Q.png" /><figcaption>Simple Queue In Node.js using Redis Server and Bull Package — Job Scheduling using Bull &amp; Redis</figcaption></figure><p>Before we jump into the coding magic, let’s quickly grasp the concept of a queue. In programming, a queue is a data structure that follows the First-In-First-Out (FIFO) principle. Imagine it as a line of people waiting for a bus — the person who arrives first gets on the bus first. Simple, right?</p><p>Using the Bull package simplifies working with Redis as a queue in Node.js. Bull is a popular Node.js job and message queue library that is built on top of Redis. It provides a simple and easy-to-use API for managing queues and processing background jobs. Let’s walk through setting up a basic queue using Bull and Redis</p><h3>Getting Started with Bull and Redis</h3><p>Firstly, you need to install <a href="https://redis.io/">Redis server</a> on your machine and run it. Then install the <a href="https://www.npmjs.com/package/bull">Bull package</a> along with the <a href="https://www.npmjs.com/package/redis">Redis Client</a>. You can install them using npm (Node Package Manager) by running the following commands in your terminal or command prompt:</p><pre>npm install bull redis</pre><h3>Creating a Basic Queue</h3><p>Now, let’s create a basic queue using Bull and Redis. In your JavaScript file (for example, queue.js), you can set up the queue like this:</p><pre>const Queue = require(&#39;bull&#39;);<br>const redisConfig = {<br>  redis: {<br>    port: 6379, // Redis server port<br>    host: &#39;localhost&#39;, // Redis server host<br>  },<br>};<br><br>const myQueue = new Queue(&#39;myQueue&#39;, redisConfig);<br><br>// Add a job to the queue<br>myQueue.add({<br>  data: {<br>    message: &#39;Hello, Queue!&#39;,<br>  },<br>});<br><br>// Process jobs from the queue<br>myQueue.process((job) =&gt; {<br>  console.log(&#39;Processing job:&#39;, job.data.message);<br>  // Add your job processing logic here<br>  // ...<br>  return Promise.resolve(); // Resolve the promise when the job processing is complete<br>});<br><br>// Event listener for completed jobs<br>myQueue.on(&#39;completed&#39;, (job, result) =&gt; {<br>  console.log(`Job ID ${job.id} completed with result:`, result);<br>});<br><br>// Event listener for failed jobs<br>myQueue.on(&#39;failed&#39;, (job, err) =&gt; {<br>  console.error(`Job ID ${job.id} failed with error:`, err);<br>});</pre><p>In this example, we’ve created a queue named ‘<strong>myQueue</strong>’. Jobs are added to the queue using the add() method, and the process() method defines the function to process the jobs. You can add your job processing logic inside the process() method.</p><h3>Running the Queue</h3><p>Before running your script, ensure that your Redis server is up and running. You can start your Node.js script by running:</p><pre>node queue.js</pre><p>Now, your queue is set up and ready to process jobs! Bull provides a lot of features and options for managing queues, such as job retries, delayed jobs, and more. Be sure to check out the Bull documentation for more advanced usage: <a href="https://github.com/OptimalBits/bull">Bull GitHub Repository</a>.</p><p>Happy coding! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5beeb2db9668" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best Practices: Setting up a callback URL/Webhook from a third-party website]]></title>
            <link>https://inayatu.medium.com/best-practices-setting-up-a-callback-url-webhook-from-a-third-party-website-2f72fd1c5684?source=rss-1930c56dbf84------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f72fd1c5684</guid>
            <category><![CDATA[callback-function]]></category>
            <category><![CDATA[webhook-integration]]></category>
            <category><![CDATA[callback]]></category>
            <category><![CDATA[failsafe]]></category>
            <category><![CDATA[webhooks]]></category>
            <dc:creator><![CDATA[Inayat Ullah]]></dc:creator>
            <pubDate>Thu, 12 Oct 2023 05:19:29 GMT</pubDate>
            <atom:updated>2023-10-12T05:43:39.912Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="webhook integration callback integration third party integration" src="https://cdn-images-1.medium.com/max/1024/1*DWo82wBTLDEO02yyAH3RMg.png" /></figure><p>Setting up a callback URL (also known as webhook) from a third-party website, such as a payment gateway, to your application is a critical aspect of ensuring smooth communication and data exchange between the services. To make sure you never miss a callback, consider the following best practices:</p><p>Setting up a callback URL (also known as webhook) from a third-party website, such as a payment gateway, to your application is a critical aspect of ensuring smooth communication and data exchange between the services. To make sure you never miss a callback, consider the following best practices:</p><p><strong>1. Use HTTPS<br></strong> Always use HTTPS for your callback URL. It encrypts the data transmitted between the services and adds an extra layer of security.</p><p><strong>2. Validate Callbacks<br></strong> Implement validation mechanisms to ensure that the incoming requests are genuinely from the third-party service. This can include using a secret key or a signature provided by the service.</p><p><strong>3. Implement Retries<br></strong> Third-party services might experience temporary issues. Implement retry mechanisms for failed callback attempts. Exponential backoff strategies can prevent overwhelming your servers during service outages.</p><p><strong>4. Acknowledge Receipt<br></strong> Always send an acknowledgment response back to the third-party service when you receive a callback. This confirms to the sender that you successfully received the data.</p><p><strong>5. Implement Timeouts<br></strong> Set up a timeout mechanism for incoming callbacks. If a callback takes too long to process, consider it failed and implement retry logic.</p><p><strong>6. Log Callbacks<br></strong> Implement robust logging for incoming callbacks. This helps in diagnosing issues, tracking transaction history, and ensuring data integrity.</p><p><strong>7. Monitor Callbacks<br></strong> Implement monitoring for your callback endpoint. Use tools that alert you if callbacks are not being received within a specified timeframe.</p><p><strong>8. Security Measures<br></strong> Regularly update and patch your server software to protect against security vulnerabilities. Input validation is crucial to prevent injection attacks.</p><p><strong>9. Whitelist IP Addresses<br></strong> If the third-party service provides a range of IP addresses from which callbacks will be sent, consider whitelisting these IPs to enhance security.</p><p><strong>10. Fail-Safe Mechanisms<br></strong> Implement fail-safe mechanisms in case your system cannot process callbacks. This might include storing the callback data in a queue for later processing or notifying an administrator.</p><p><strong>11. Documentation and Support<br></strong> Follow the documentation provided by the third-party service thoroughly. If issues arise, reach out to their support team for assistance.</p><p><strong>12. Regular Testing<br></strong> Regularly test your callback endpoint using simulation tools or by coordinating with the third-party service’s sandbox environment to ensure everything is working as expected.</p><p>By following these best practices, you can set up a robust callback system that ensures you never miss important data from third-party services. Remember that each service might have specific requirements and nuances, so always refer to their documentation for service-specific best practices.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f72fd1c5684" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Greengrass | How to create greengrass group via API (NodeJs)]]></title>
            <link>https://inayatu.medium.com/aws-greengrass-how-to-create-greengrass-group-via-api-nodejs-9ef6b6ff8fc9?source=rss-1930c56dbf84------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ef6b6ff8fc9</guid>
            <category><![CDATA[aws-sdk]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[greengrass]]></category>
            <dc:creator><![CDATA[Inayat Ullah]]></dc:creator>
            <pubDate>Tue, 04 Sep 2018 13:39:57 GMT</pubDate>
            <atom:updated>2018-09-05T06:05:24.403Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*miBTM2NDIC00Wh676JDTsQ.png" /></figure><h3>AWS Greengrass | How to create greengrass group via API (Node.js)</h3><p>We all know the coming era is an era of IoT so if you are programmer and keen to learn about IoT then AWS IoT is one of the cool platform to start with. <br>But if you are newbie here you will face quite a problems while setting up your system even if you go through the official AWS documentation.</p><p>I found myself stuck and helpless for days when I tried to do things programmatically which I was able to do through AWS console easily. I don’t want the same for you so, don’t worry, I will help you out!</p><p>__ Get ready to get dirty with code!!!</p><p>I am working in Node.js, where I want to create AWS greengrass group using aws-sdk. When you create greengrass group using AWS console you just click on create group and it does all the necessary work for you on the go from creating core device for that group to creating cert and keys of that core device, policy and attaching that cert with created core device but on the backend all these are created separately and linked to each other at the end, that’s what we are going to do. Stay with me … you gonna do it.</p><p>Given below is step wise operations we will be performing:</p><ol><li>Create a thing (core device for GG group to be created)</li><li>Create cert and key for core thing created in step 1</li><li>Attach a policy with created cert and key above. I am assuming u have already created a policy document on AWS console, we will use just use its name</li><li>Create greengrass core definition by using core device Id, core device Arn and cert and key</li><li>Finally create greengrass group using the core definition created in previous step.</li></ol><p>Given below is the code, explore by yourself and enjoy!</p><pre>var AWS = require(&#39;aws-sdk&#39;);</pre><pre>AWS.config.update({<br> &quot;endpoint&quot;: &quot;<a href="https://greengrass.us-west-2.amazonaws.com/">https://greengrass.<strong><em>your-region</em></strong>.amazonaws.com</a>&quot;,<br> &quot;accessKeyId&quot;: &quot;yourAccessKeyId&quot;, //IAM User&#39;s<br> &quot;secretAccessKey&quot;: &quot;secretAccessKey&quot; //IAM User&#39;s<br>});</pre><pre>var greengrass = new AWS.Greengrass();</pre><pre>AWS.config.update({<br> &quot;endpoint&quot;: &quot;<a href="http://iot.us-west-2.amazonaws.com/">http://iot.</a><a href="https://greengrass.us-west-2.amazonaws.com/"><strong><em>your-region</em></strong></a><a href="http://iot.us-west-2.amazonaws.com/">.amazonaws.com</a>&quot;, <br> &quot;accessKeyId&quot;: &quot;yourAccessKeyId&quot;, //IAM User&#39;s<br> &quot;secretAccessKey&quot;: &quot;secretAccessKey&quot; //IAM User&#39;s<br>});</pre><pre>var iot = new AWS.Iot();</pre><pre>var greengrass = new AWS.Greengrass();</pre><pre>var GG_Group_Name = &#39;GG-DEMO-GROUP&#39;</pre><pre>var params = {<br>  thingName: GG_Group_Name+&#39;_Core&#39;,<br>  thingTypeName: &#39;core_device&#39;<br>};<br>iot.createThing(params, function(err, iotThing) {<br>  if (err){<br>    res.status(400).send({<br>      message: err.message<br>    });<br>  }<br>  else{<br>    console.log(&#39;GG group Core created ..&#39;);<br>    // create certificate and keys<br>    params = {<br>      setAsActive: true<br>    };<br>    iot.createKeysAndCertificate(params, function(err, certAndKey) {<br>      if (err){<br>        res.status(400).send({<br>          message: err.message<br>        });<br>      }<br>      else{<br>        console.log(&#39;certificate and key created ...&#39;);</pre><pre>// attach policy to certificate<br>        params = {<br>          policyName: &#39;policy-name&#39;, /* required */ // assuming you have already policy created<br>          principal: certAndKey.certificateArn /* required */<br>        };<br>        iot.attachPrincipalPolicy(params, function(err, data) {<br>          if (err){<br>            res.json({&#39;attachPrincipalPolicy error:&#39;: err})<br>          }<br>          else{<br>            console.log(&#39;attached policy with created certificate...&#39;);</pre><pre>//attched created certificate to the created core thing<br>            params = {<br>              principal: certAndKey.certificateArn, /* required */<br>              thingName: GG_Group_Name+&#39;_Core&#39; /* required */<br>            };<br>            iot.attachThingPrincipal(params, function(err, data) {<br>              if (err) {<br>                res.status(400).send({<br>                  message: err.message<br>                });<br>              }<br>              else{<br>                console.log(&#39;certificate attached to core device&#39;);</pre><pre>// create core definition <br>                params = {<br>                  InitialVersion: {<br>                    Cores: [<br>                    {<br>                        CertificateArn: certAndKey.certificateArn, //cert of core device<br>                        Id: iotThing.thingId, //id of core device device<br>                        // SyncShadow: true || false,<br>                        ThingArn: iotThing.thingArn //core thing arn<br>                      },<br>                      /* more items */<br>                      ]<br>                    },<br>                    Name: iotThing.thingName<br>                  };<br>                  greengrass.createCoreDefinition(params, function(err, coreDef) {<br>                    if (err){<br>                      res.status(400).send({<br>                        message: err.message<br>                      });<br>                    }<br>                    else{<br>                      console.log(&#39;core definition created ..&#39;);<br>                    // now create greengrass group<br>                    params = {<br>                      InitialVersion: {<br>                        CoreDefinitionVersionArn: coreDef.LatestVersionArn<br>                      },<br>                      Name: GG_Group_Name<br>                    };<br>                    greengrass.createGroup(params, function(err, ggGroup) {<br>                      if (err){<br>                        res.status(400).send({<br>                          message: err.message<br>                        });<br>                      }<br>                      else{<br>                        console.log(&#39;GG group&#39;+GG_Group_Name+&#39;created ..&#39;);<br>                        var resp = {<br>                          &#39;core&#39;: iotThing,<br>                          &#39;certAndKey&#39;: certAndKey,<br>                          &#39;ggGroup&#39;: ggGroup,<br>                          &#39;coreDef&#39;: coreDef<br>                        };<br>                        res.json(resp);<br>                      }<br>                    });<br>                  }<br>                });</pre><pre>}<br>              }); <br>          }<br>        });<br>      }<br>    });<br>  }<br>});</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ef6b6ff8fc9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>