<?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 Youssef Mahdi on Medium]]></title>
        <description><![CDATA[Stories by Youssef Mahdi on Medium]]></description>
        <link>https://medium.com/@y.mahdi?source=rss-348657328edf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Aw0F_ZIH6blqstDPRCdEZg.jpeg</url>
            <title>Stories by Youssef Mahdi on Medium</title>
            <link>https://medium.com/@y.mahdi?source=rss-348657328edf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:57:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@y.mahdi/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[CodeBuild: Automated tests using Cypress]]></title>
            <link>https://medium.com/@y.mahdi/codebuild-automated-tests-using-cypress-bfca1f43a41e?source=rss-348657328edf------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfca1f43a41e</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[codebuild]]></category>
            <category><![CDATA[test-automation]]></category>
            <dc:creator><![CDATA[Youssef Mahdi]]></dc:creator>
            <pubDate>Sat, 22 Jan 2022 17:19:34 GMT</pubDate>
            <atom:updated>2022-01-23T09:38:39.911Z</atom:updated>
            <content:encoded><![CDATA[<p>As a devops engineer, one of the challenges you face is building automated CI/CD pipelines so developers are free of manual tasks thus their productivity will be increased. Building and deploying code to multiple environments can be very risky if you don’t run the right tests.</p><p><strong>Cypress</strong></p><p>Cypress is a javascript-based end to end testing framework. Cypress will open your project in a new browser; a visual interface of the tests that are available and the progress of each one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*X88pOslBchS_8wypZk5agA.gif" /></figure><p><strong>Running automated test in CodeBuild</strong></p><p>In order to automate the aspect of testing ,building, and allowing of continuous delivery of the software ,we will add a custom setup to our react application.</p><ul><li>Start by creating a react application:</li></ul><pre><strong>npx</strong> create-react-app my-app — template <strong>typescript</strong></pre><ul><li>Install the following libraries:</li></ul><pre>npm i cypress @cypress/instrument-cra @cypress/code-coverage start-server-and-test</pre><ul><li>In the root folder, create cypress.json file :</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f28432cb5ec4e740955099a7af63f838/href">https://medium.com/media/f28432cb5ec4e740955099a7af63f838/href</a></iframe><ul><li>src/cypress/support/ :</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46fc0bea2bfae34caa55f531cbe5fd6e/href">https://medium.com/media/46fc0bea2bfae34caa55f531cbe5fd6e/href</a></iframe><ul><li>src/cypress/plugins/ :</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0b476424ac9cb32ada9e769708ca5b5/href">https://medium.com/media/e0b476424ac9cb32ada9e769708ca5b5/href</a></iframe><ul><li>In the following folder, add the tests. src/cypress/integration/ :</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09262db107eaa7112aa614381974b112/href">https://medium.com/media/09262db107eaa7112aa614381974b112/href</a></iframe><ul><li>Finally in package.json :</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc46a1cd06d42c280969b8ae248a492f/href">https://medium.com/media/bc46a1cd06d42c280969b8ae248a492f/href</a></iframe><ul><li>After running the following command ‘npm run cypress:run’</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KFjtTi07PtdgjMizjxuoSg.png" /></figure><p><strong>Writing our buildspec.yml file</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31e469411407a35e121e24193013c0e8/href">https://medium.com/media/31e469411407a35e121e24193013c0e8/href</a></iframe><p><strong>Amazon Codebuild</strong></p><p>1- First, create a new codebuild project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yfQ2c41q-jrGViN9NEzGow.png" /></figure><p>2- After running two tests. One of them I made it to fail on purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L5gK4V8sWChLCjWzD5rZXQ.png" /></figure><p><strong>Conclusion</strong></p><p>The real purpose of devops culture is releasing software in small amount of time and avoiding errors. So keep in mind the process of automated tests while creating CI/CD pipelines.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfca1f43a41e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Pubnub as a microservice]]></title>
            <link>https://awstip.com/implementing-pubnub-as-a-microservice-6d517670f270?source=rss-348657328edf------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d517670f270</guid>
            <category><![CDATA[pubnub-function]]></category>
            <category><![CDATA[pubnub-react]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[pubnub]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Youssef Mahdi]]></dc:creator>
            <pubDate>Wed, 19 Jan 2022 18:36:48 GMT</pubDate>
            <atom:updated>2022-01-27T08:15:45.452Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIyYKFkEV7wcNJ8vS2Halw.png" /></figure><p>Pubnub is a platform that provides messaging features which allow you to build direct, group, and large scale chat for your users. In this article I will explain how to implement this features in react application and how to use AWS in managing our application.</p><p><strong>Registering to Pubnub</strong></p><p>Before moving forward we need to create an account in Pubnub and register our application in order to gain access to our keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wkSu7zPIGjkclG4taIpF6A.png" /><figcaption>Vist <a href="http://www.pubnub.com/">www.pubnub.com</a></figcaption></figure><p>After the generation of keys, we will enable server access manager.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ksXoShUk9VSnpR8R2tzV7w.png" /></figure><p><strong>Building our cloud infrastructure</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GM6B-M5hUN9gZWadU0jKBQ.png" /></figure><p>In our AWS account we will create a rest Api that will invoke a lambda function which will check the identity of the user and fetch his channels from our database. If the user is allowed to use this feature we will generate a Pubnub token which he can use it as an end user.</p><p>The following code illustrate how the token is generated:</p><ul><li>First we will fetch the channels for the user with following username.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d68612d841966091e6da780d995f0a6/href">https://medium.com/media/1d68612d841966091e6da780d995f0a6/href</a></iframe><ul><li>Then we will create an object which contains the channels which the token will have permissions to read and write.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9491c6c4fceb2614998104571eac20f/href">https://medium.com/media/e9491c6c4fceb2614998104571eac20f/href</a></iframe><p>We will also add a channel that the system will use to send notifications to our end user.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dce464329d4899c4217f1ba1f638a9c8/href">https://medium.com/media/dce464329d4899c4217f1ba1f638a9c8/href</a></iframe><ul><li>After listing the channels that the user will have access to, we will generate a token so the user can listen to them.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba5b17ad8489f1c2def0da917e88f864/href">https://medium.com/media/ba5b17ad8489f1c2def0da917e88f864/href</a></iframe><p>Finally we will deploy this method using aws cdk. Check the GitHub repository for the full code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/acea2bfbf22d89315b50c880adda1675/href">https://medium.com/media/acea2bfbf22d89315b50c880adda1675/href</a></iframe><p><strong>Fetching channels and token on client side</strong></p><p>We will use the react components pubnub provided to us. You can see the the documentation on <a href="https://pubnub.github.io/react-chat-components/docs/?path=/docs/custom-hooks-about--page">https://pubnub.github.io/react-chat-components/docs/?path=/docs/custom-hooks-about--page</a></p><p>The full code is in my GitHub account.</p><p><strong>Create a simple notification service</strong></p><p>The final part of this solution is about implementing pubnub as a notification center. If you recall earlier we added a channel that can be accessed only by system admin. In our React project we will handle messages from channel called ‘-admin’ differently.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f87ea77c09bc647846232e969ce386ed/href">https://medium.com/media/f87ea77c09bc647846232e969ce386ed/href</a></iframe><p>We added a listener to do extra actions when receiving a message.</p><p>The lambda function below illustrate how a token is generated before sending the message. The username of the sender will be called admin. So we can distinguish it from others messages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GyjIJ5yqRxPlzCk7bDjptw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TPZdRJjQAboB5x7gqxcd-A.png" /></figure><p><strong>Conclusion</strong></p><p>Thanks to Pubnub we easily implemented two features that can be used in most projects.</p><p>To launch the project make sure to deploy the cdk in your amazon cloud account. Also replace Pubnub keys with your own keys.</p><p>Follow me on twitter: <a href="https://twitter.com/youssefmahdi25">https://twitter.com/youssefmahdi25</a></p><p>Follow me on linkedIn: <a href="https://www.linkedin.com/in/youssef-mahdi-ab6ba51b7/">https://www.linkedin.com/in/youssef-mahdi-ab6ba51b7/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d517670f270" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/implementing-pubnub-as-a-microservice-6d517670f270">Implementing Pubnub as a microservice</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>