<?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 Syed Kumail Rizvi on Medium]]></title>
        <description><![CDATA[Stories by Syed Kumail Rizvi on Medium]]></description>
        <link>https://medium.com/@rizvikumail98?source=rss-ec76ca0ae456------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PS8buuxBt3Kc4OeVDlG16g.jpeg</url>
            <title>Stories by Syed Kumail Rizvi on Medium</title>
            <link>https://medium.com/@rizvikumail98?source=rss-ec76ca0ae456------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 15:35:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rizvikumail98/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[Tips To Optimise API Performance (Using Java & Node.js)]]></title>
            <link>https://medium.com/@rizvikumail98/tips-to-optimise-api-performance-using-java-node-js-eed15783b43f?source=rss-ec76ca0ae456------2</link>
            <guid isPermaLink="false">https://medium.com/p/eed15783b43f</guid>
            <category><![CDATA[api-optimization]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <dc:creator><![CDATA[Syed Kumail Rizvi]]></dc:creator>
            <pubDate>Thu, 21 Mar 2024 17:34:40 GMT</pubDate>
            <atom:updated>2024-03-21T17:34:40.778Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you tired of slow API response? Try these tips.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GCoRRJeDORRO0Y-f" /><figcaption>Photo by <a href="https://unsplash.com/@nbabrams?utm_source=medium&amp;utm_medium=referral">Nick Abrams</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>So, it is all about experience, while I was developing software I faced this issue and tried to do a lot of R&amp;D but was hardly able to reduce the response time or improve my API performance, then, I did what Software Developers do best, which is Googling about our problems and it came out for me as a Salvatore. Hence, sharing what I learned.</p><p><strong>GENERAL TECHNIQUES</strong></p><ol><li>Profiling &amp; Monitoring<br>Before optimization we should identify the bottlenecks, for that we can use profilers like <a href="https://www.ej-technologies.com/products/jprofiler/overview.html">JProfiler</a>(Java) or built-in profiler (Node). These help you find the section of the code which is slowing down your API or in other words we can say to identify redundant code. <br>There are some Monitoring tools available that will help you in analyzing the metrics of response time, throughput, etc.</li><li>Caching<br>This is a very good practice of storing frequently accessed data in memory or local storage( <a href="https://www.baeldung.com/guava-cache">Guava Cache</a>(Java)), using invalidation strategies will ensure that cached data remains correct. Explore your code base and search for areas where you can implement caching strategies. Unnecessarily making a database call can be avoided using this method.</li><li>Database Optimisation<br>Making our queries to the database efficient and optimized, selecting only the required columns, and applying database optimization techniques. In SQL-based DB, writing efficient SQL queries will help optimize the output.</li><li>Asynchronous Operations<br>In Node.js we can take advantage of non-blocking I/O operations, and the use of async and promises might be helpful to complete tasks efficiently. In Java achieving asynchronous behavior is complex but can be done, if knowing the concepts of Threads, Callables, and Future objects.</li></ol><p><strong>JAVA-SPECIFIC TECHNIQUES</strong></p><ol><li>Use of Efficient Data Structures<br>In Java choosing the correct data structure is very important as each data structure has some pros and cons, it all depends on your use case, so we should be aware of which data structure we should choose. For example, a HashMap is good for looking for an element and updating its value, its time complexity is O(1) which is a constant time complexity and considered as a good one. So, be confident and wise in choosing the data structure.</li><li>Garbage Collection Tuning<br>Excessive Garbage collection might result in bad performance of the code. If necessary monitor garbage collection behavior, although it is an automatic behavior of the JVM, we can set parameters by setting min and max heap size keeping in mind to avoid GC cycles.</li></ol><p><strong>NODE-SPECIFIC TECHNIQUES</strong></p><ol><li>Cluster Mode<br>Utilize Node.js cluster mode which helps in handling multiple requests at the same time, by utilizing multiple cores of the CPU.</li><li>Minimize Dependencies<br>Large dependency trees can impact performance. Evaluate dependencies and consider alternatives if possible.</li></ol><p>These are the techniques that I discovered while trying to study API optimization, although there can be more like code optimization, load balancer, streamlining etc. Hoping this might be insightful. Keep on Coding, Learning, and Reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eed15783b43f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Node.js and JWT: The Perfect Match for Secure and Scalable APIs]]></title>
            <link>https://medium.com/@rizvikumail98/node-js-and-jwt-the-perfect-match-for-secure-and-scalable-apis-3be73ba60c27?source=rss-ec76ca0ae456------2</link>
            <guid isPermaLink="false">https://medium.com/p/3be73ba60c27</guid>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[jwt-authentication]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[node]]></category>
            <dc:creator><![CDATA[Syed Kumail Rizvi]]></dc:creator>
            <pubDate>Fri, 23 Feb 2024 14:22:42 GMT</pubDate>
            <atom:updated>2024-02-23T14:22:42.513Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rLt8MMOFB0w-m_nw" /><figcaption>Photo by <a href="https://unsplash.com/@franckinjapan?utm_source=medium&amp;utm_medium=referral">Franck</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>JSON -&gt; JavaScript Object Notation</p><pre>//JSON Object Example<br>{<br>  &quot;key&quot;: &quot;value&quot;<br>}</pre><h3>What is JWT?</h3><p>JWT is a widely known practice for transmitting data between two parties usually client and server. This technique enables the secure transmission of data, maintaining the integrity and consistency of the data being transferred.</p><p>In Short:</p><ul><li>A compact, self-contained way to securely transmit information between parties as a JSON object.</li><li>Used for authentication and authorization in web applications, APIs, and mobile apps.</li></ul><p>Key Concepts of JWT</p><ol><li>Headers:- It contains metadata like the token type (JWT), signing algorithm(HS256, RS256, etc), and optional fields like issuer(iss) and audience (aud).</li><li>Payload:- It contains the actual data, such as user ID, expiration time, role, etc.</li><li>Signature:- It maintains the integrity of the token, generated using a secret key or a private key.</li></ol><p>Advantages:</p><p>=&gt; Stateless:- No need to store session details<br>=&gt; CORS (Cross-Origin Resource Sharing) friendly<br>=&gt; Secure<br>=&gt; Flexible</p><p>Flow of JWT</p><ol><li>User Login: The user logs in to the system with its credentials, and sends a request to the server.</li><li>Validation:- Credentials provided by the user are validated on the Back End.</li><li>Token Generation: The server generates a token signed with the secret key in the environment variables.</li><li>Token Response: The token is sent to the client as a response, which is stored by the client either locally or as cookies.</li><li>Secured Subsequent Requests: The client has to attach the JWT in authorization headers with each request sent to the servers.</li><li>Authentication/Authorization: Based on the token and claims the user/client request is accepted or denied by the server.</li></ol><p>Implementing JWT using Node.js</p><p>We, first need to install an npm package ‘jsonwebtoken’</p><pre>npm install jsonwebtoken</pre><p>Second, we would be storing the token in cookies, so we need to install the cookie-parser package from the npm.</p><pre>npm install cookie-parser</pre><p>Then, create a strong, random secret key and place it in your .env file, make sure that this key is not exposed to anyone.</p><p>Eg:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*2IwadOv1twE08nHf5wBb_w.png" /></figure><p>The next step comes in generating the token and appending it to the user (not saving the token with the user, just append the token)</p><pre>import jwt from &#39;jsonwebtoken&#39;</pre><pre>//extracting User details from the Database on the basis of email<br>const user = await User.findOne({req.body.email})</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HZOOa8EFv0yKz1JnmP_Zkg.png" /></figure><pre>user.password = undefined; <br>//so that password is not sent back in response<br>//always a good practice to store the password as a hash Value (use bcrypt.js)</pre><p>After generating the token, we need to store it in the cookie</p><pre>//inside your index.js/server.js<br>import cookieParser from &#39;cookie-parser&#39;<br><br>app.use(cookieParser()) //this will help us have a cookie instance in our response</pre><pre> //cookie section<br>  const cookieOption = {<br>    expires: new Date(Date.now() + 1 * 24 * 60 * 60 * 1000),<br>    httpOnly: true<br>  };<br>  res.status(200).cookie(&quot;token&quot;, token, cookieOption).json({<br>    success: true,<br>    token: token,<br>  })</pre><p>Once, the tokens are generated and the response is sent back to the client <br>then we need to verify the token in each subsequent request, for that, we can make a middleware in our application such as checkAuth.js</p><pre>import jwt from &#39;jsonwebtoken&#39;;<br>import User from &#39;../models/UserModel.js&#39;;<br><br>//check and verify token<br>export const checkAuth = async (req, res, next) =&gt; {<br>    try {<br>        let token = req.cookies.token;<br>        //validate if the token is present<br>        if (!token) {<br>            return res.status(401).json({ message: &quot;No Token, Authorization Denied&quot; });<br>        }<br>        //verify the token using jwt.verify() method<br>        const decoded = jwt.verify(token, process.env.JWT_SECRET);<br>        //decoded will have the data of payload<br>        <br>        //extract the user on the basis of id<br>        req.user = await User.findById(decoded.id);<br><br>        if (!req.user) {<br>            return res.status(401).json({ message: &quot;No User Found&quot; });<br>        }<br><br>        req.user.password = undefined;<br>        next();<br>    } catch (err) {<br>        console.log(err);<br>        return res.status(500).json({ message: &quot;Server Error&quot; });<br>    }<br>}<br><br></pre><p>Inside your server.js or if you have indexRoutes.js file then inside that you can use this checkAuth as a middleware.</p><pre>import { checkAuth } from &#39;../middlewares/checkAuth.js&#39;;<br>app.use(checkAuth);</pre><p>The rest of the routes can be used below the checkAuth middleware.<br>This, is the basic implementation of JWT using Node.js, although we can always have some more optimization in our code and we can make it more production-ready by following the documentation available on the Internet.</p><p>Hope that your concepts of JWT are much clearer now, will be bringing more of tech-related stuff, so stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3be73ba60c27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cron in JavaScript]]></title>
            <link>https://medium.com/@rizvikumail98/cron-in-javascript-7cbf6cf81be7?source=rss-ec76ca0ae456------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cbf6cf81be7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[task-scheduler]]></category>
            <category><![CDATA[node-cron]]></category>
            <dc:creator><![CDATA[Syed Kumail Rizvi]]></dc:creator>
            <pubDate>Fri, 23 Feb 2024 07:41:34 GMT</pubDate>
            <atom:updated>2024-02-23T07:41:34.281Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7D-3BAwaytdeb32w" /><figcaption>Photo by <a href="https://unsplash.com/@mostafa_mahmoudi24?utm_source=medium&amp;utm_medium=referral">mostafa mahmoudi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Although JS does not have inbuilt functionality to allow scheduling features, many libraries can be incorporated into our projects to enable us to use scheduler-like functions, and these libraries which are particularly mostly used in the industry are the “<strong><em>node-cron and cron </em></strong>” libraries.</p><p>Before jumping into the practical implementation of these libraries, let me just discuss the concept of a scheduler in programming.</p><p>In the vast and evergrowing world of Computer Science, schedulers have been an important part of efficiently executing tasks in multi-tasking environments and resource management in operating systems. Schedulers can be of various types such as Operating System schedulers and Task-oriented schedulers, etc.</p><p>The main purpose of a Scheduler is to schedule a task in the best possible and required manner, allocate resources, and perform and store a task in the scheduling queue, there are various cases where a scheduler can be implemented, take an example of scheduling our mail on a particular day and time (requires task scheduler). There can be a scenario where we want to apply a scheduler in our application, and hence we need to know how to do it.</p><p>In this example, I will be using node.js to apply a task scheduler which will execute a function on the specified time and will return an output.<br>I will use the node-cron library to achieve my goal.</p><p>First, we need to install node-cron</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*PVjVvpb3UHRlXlkTaxCYsQ.png" /></figure><p>After, successfully installing node-cron we need to require or import it in our .js file where you want to apply the task scheduler</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*rVVCAKEfPfY2X0MnzJHMAA.png" /></figure><p>Once, you have the required cron in your file, then write the functional logic which, you want to schedule, in my case the logic is to say Hello world and print Date.now()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*SIou1qYg3So0SYhc17dRWQ.png" /></figure><p>Once you are done with your logic implementation, then comes the part of scheduling the task using cron.schedule() method. This method accepts a cron expression and a callback function, we can easily validate the cron expression using cron.validate() method which returns a boolean value, the schedule function can be applied like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*oeaG-d0sz7ibawd12SnM3g.png" /></figure><p>The cron expression is like ( min, hrs, day, month, year ), and above (*) is used to indicate that execute the task() each minute.</p><p>On running this .js file using node command this output was observed at an interval of 1 min.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*yNaKbBNN2rfjV6ximoNZOA.png" /></figure><p>The cron object has many other functions such as getTasks() and validate() which are used to get an array of task objects that are scheduled and to validate the expression as per cron expression criteria respectively.</p><p>Hope, you are able to understand the concept of a task scheduler and how to implement it using the node-cron library.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cbf6cf81be7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Do You Condemn?]]></title>
            <link>https://medium.com/@rizvikumail98/do-you-condemn-db08e2aa23cd?source=rss-ec76ca0ae456------2</link>
            <guid isPermaLink="false">https://medium.com/p/db08e2aa23cd</guid>
            <category><![CDATA[gaza]]></category>
            <category><![CDATA[genocide]]></category>
            <category><![CDATA[israel-palestine-conflict]]></category>
            <dc:creator><![CDATA[Syed Kumail Rizvi]]></dc:creator>
            <pubDate>Sat, 04 Nov 2023 08:34:38 GMT</pubDate>
            <atom:updated>2023-11-04T08:34:38.919Z</atom:updated>
            <content:encoded><![CDATA[<p>A question posed to conceal the truth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P8xZGClbRz5uqlak" /><figcaption>Photo by <a href="https://unsplash.com/@bogomi?utm_source=medium&amp;utm_medium=referral">Bogomil Mihaylov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>An eye for an eye will make the whole world blind!<br>M.K Gandhi</blockquote><p>“Do you Condemn?”<br>This has been the case from the inception and is still an active way of misleading “us” from the actual facts and putting a cover on their doings.<br>But it’s high time for us to look at the picture from a broader perspective to get a better understanding of the entire matter.</p><p>Yes, I do condemn things that are inhuman and by any means affect our social beings. However, this does not absolve them from being held accountable for their inhumane actions carried out under the guise of self-defense.</p><p>They ask after killing a quarter million people do you condemn “Pearl Harbor”, and what about Hiroshima &amp; Nagasaki, has anyone seen them being held responsible and answerable to those attacks, were they guilty of that massacre? We get no response in that context……. and this is nothing other than <strong>Double Standards </strong>of the great powers of the world.</p><p>Today they say that the attack by Hamas on October 7, 2023, was wrong, who says it wasn’t but is there any acknowledgment of the attacks on hospitals, refuge camps, and homes of civilians? Do they condemn this?</p><p>Do you find yourself protected in this world of double standards? It’s a major concern for us.<br>Again I want to say that I do condemn all inhuman actions and I seek peace in this world.<br>But this doesn’t end here, my question is that</p><p>DO THEY CONDEMN?<br> . Carpet Bombing on civilians.<br> . Airstrike on Hospitals.<br> . Death of +9k Palestinians.<br> . Death of innocent children.</p><p>And if they do, then there should be a ceasefire.</p><p>A poem written by a human with a pure heart…</p><blockquote>It Bleeds my heart<br>As pictures I see ,<br>Of bloodshed and bombings<br>And massacres on streets<br>Refugees like you<br>No country should greet<br>Backstabbed those people<br>Who heard your plea<br>Usurped Their lands<br>Their dreams Their glee<br>Flourished Your Kind<br>Didn’t let Them breathe<br>Took freedom of those<br>Who gave refuge to Thee<br>Countless years of ruthlessness<br>Your presence is a catastrophe<br>How long did you plan to suffocate<br>This retaliation was bound to be<br>Violence bloodshed atrocities <br>Have been your legacy<br>As you taste your own medicine<br>Why appalled at its brutality<br>“ Justice shall prevail “<br>Feedom will be sought<br>Your reign was but a fallacy <br>Oppression has erupted this volcano<br>It’s time to end your tyranny<br>Battles are won with intentions not numbers<br>This apartheid will soon be a History !!!<br>:- <strong><em>Jaza</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db08e2aa23cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>