<?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 Asif Imtiaz Shaafi on Medium]]></title>
        <description><![CDATA[Stories by Asif Imtiaz Shaafi on Medium]]></description>
        <link>https://medium.com/@asifimtiazshaafi?source=rss-ce042d8705ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mrA1Gq59KzpB9UBAx1nTIA.jpeg</url>
            <title>Stories by Asif Imtiaz Shaafi on Medium</title>
            <link>https://medium.com/@asifimtiazshaafi?source=rss-ce042d8705ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 10:37:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@asifimtiazshaafi/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[Publishing a React website on AWS with AWS amplify and AWS CloudFront with Custom Domain (Part 2)]]></title>
            <link>https://medium.com/craftsmenltd/publishing-a-react-website-on-aws-with-aws-amplify-and-aws-cloudfront-with-custom-domain-part-2-4651983f87e?source=rss-ce042d8705ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/4651983f87e</guid>
            <category><![CDATA[react-web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[aws-cloudfront]]></category>
            <category><![CDATA[aws-amplify]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Asif Imtiaz Shaafi]]></dc:creator>
            <pubDate>Thu, 24 Dec 2020 12:34:14 GMT</pubDate>
            <atom:updated>2020-12-27T05:40:51.540Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*jw6Xv64p6oWcInHL3kfiRQ.png" /><figcaption>React with AWS Amplify and CloudFront</figcaption></figure><p>This post is a part of the series which will help you publish your React based project/website on AWS using AWS Amplify and AWS CloudFront. This part will walk you through the steps to setup AWS CloudFront so that you can access your website using any domain of your own.</p><p>If you want to learn about how to upload your React project on AWS using AWS Amplify or if you just want to follow along with this whole series, check out <a href="http://bit.ly/3rtpKqi"><strong><em>Part 1</em></strong></a>. This post will continue from where we left off in the first part. So it’s recommended that you go through that one first.</p><blockquote><a href="http://bit.ly/3rtpKqi">Part 1 covers the React project creation and AWS Amplify part.</a></blockquote><blockquote>Part 2 covers the CloudFront configuration and custom domain setup part.</blockquote><h3>Before You Begin (part 2)👀…</h3><p>As this post uses AWS, we will assume that you already have an AWS account or have access to an account, as you will need to use your credentials for AWS Amplify and will need to go to AWS console and configure AWS CloudFront. If you still think this post can help you, then let’s get into it.</p><h3>Create an AWS CloudFront Distribution</h3><p>Well, to begin with, what we need to do first?🤔 Of course create a new CloudFront distribution, what else, right? 😎 So let’s head to the <a href="https://console.aws.amazon.com/cloudfront/home">AWS CloudFront console home page</a> and select the <strong><em>Create Distribution</em></strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ay1VoTGcUyoJQHTAl8QFkA.png" /><figcaption>CloudFront Home page</figcaption></figure><p>After that, it will take you to the delivery method selection page, where, as of the time of this post writing, you will be given two(2) options to choose from, one is <strong><em>Web</em></strong>, the other one is <strong><em>RTMP</em></strong> (which will be discontinued from<strong> December 31, 2020</strong>). We will be selecting the <strong>Web </strong>one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JNGMkmcnR3N204ECHTbhjg.png" /></figure><p>Now we will actually get the main form to create a new CloudFront Distribution.</p><p>If you click on the <em>Origin Domain Name </em>input box, AWS will suggest the S3 buckets you have along with some other options. We need to select the one we created in <a href="http://bit.ly/3rtpKqi"><strong><em>Part 1</em></strong></a><strong><em>, </em></strong>which was <em>reactawsamplify-20201222013512-hostingbucket-dev. </em>But there is a catch, we can’t just select the bucket from the drop-down as it will only point the distribution to the bucket, which we don’t want. We want the distribution to point at the hosting site. So instead of just writing the name of the bucket, we will write the entire hosting URL.</p><p>By this time, you might be wondering how the hell you will get the URL?🤔 Do you have to publish the project with AWS Amplify again just to get the URL?😨 Well, don’t worry about that, you don’t have to go to such length.😌 There is an easy and convenient way to get that. Just go into the S3 bucket, and select the <em>Properties</em> tab on the top.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ovaOR-ou3yNfng3PbcvyKQ.png" /><figcaption>Select the <strong>Properties</strong> tab on the S3 bucket</figcaption></figure><p>On that page, went to the bottom of the page and you will find a card named <strong><em>Static website hosting</em></strong> and there you will find the desired URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PFgqCulywltUBvNZlD25lg.png" /><figcaption>The URL of the hosting site</figcaption></figure><p>Copy that URL and paste it on the CloudFront Distribution page’s <strong>Origin Domain Name </strong>input field and click anywhere outside. It will load the necessary information into the other input fields.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*xteYAXPP9Ywx-WxtemvI1w.png" /><figcaption>Paste the URL in this input box</figcaption></figure><p>Now let’s set up the other fields that we need. We will keep the default value for the following fields: <strong>Enable Origin Shield, Origin Connection Attempts, Origin Connection Timeout, Smooth Streaming, Restrict Viewer Access(Use Signed URLs or Signed Cookies), Compress Objects Automatically, Supported HTTP Versions, Enable IPv6.</strong></p><p>So let’s start customizing the <strong>Default Cache Behavior Settings</strong>.</p><ul><li>1st of all, we will change the <strong>Viewer Protocol Policy </strong>settings. You can keep it as it is, but it’s recommended to change it to <em>Redirect HTTP to HTTPS.</em></li><li>2nd, as our current website doesn’t have any PUT, POST, or DELETE operations, we will not change <strong>Allowed HTTP Methods. </strong>But if you have a form or you communicate with an API, then you need to select the <em>GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE </em>option.</li><li>3rd, for the <strong>Cache and origin request settings, </strong>we’ll change it to <em>Use legacy cache settings </em>as we don’t want to keep any cache. If you want to keep it, don’t change the settings.</li><li>If in the 3rd one, you selected the <em>Use legacy cache settings, </em>then you will get an <strong>Object Caching </strong>option. Which we will change to <em>Customize </em>and then set the <strong>Minimum TTL, Maximum TTL, Default TTL </strong>to 0 (zero). This will help the users to get up-to-date content each time they reload the page.</li></ul><p>This is the end result so far that we have implemented in the distribution page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*PLL1P8up4KLYD7NxVvabBg.png" /><figcaption>The settings we implemented so far in the previous steps</figcaption></figure><p>Now it’s time for the <strong>Distribution Settings</strong> part. In this part, we will actually keep most of the things as it is, but this is the place where we will set up the custom domain. You can do that later so we will go through the process for now and keep all the default values. Just click <strong>Create Distribution</strong> at the bottom and you are done!!</p><p>You will be taken to the CloudFront home page and you will find the distribution you just created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bURak5PydL5uFUgDka4SPA.png" /><figcaption>You will find the distribution on the CloudFront home page</figcaption></figure><p>It takes some time for the distribution to be deployed for the first time. When it’s done, you will the <strong><em>Status </em></strong>as <strong>Deployed</strong>. When that is ready, you can copy the <strong>Domain Name </strong>and paste it in the browser and you will see it’s showing the website you hosted on the S3 bucket! So now you don’t have to remember the long S3 bucket hosting URL just to visit the website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G-vSDfvUbmVAv-FB_rYucQ.png" /><figcaption>Use the URL from the domain name to visit the website.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dvJWalj6hALBjhYKVwDpxw.png" /><figcaption>Website loading using the Domain name from the CloudFront</figcaption></figure><h3>Setting up Custom Domain</h3><p>For setting the custom domain, we need two things.</p><ol><li>A registered domain and access to that domain’s DNS setting or access to the mails for that domain.</li><li>A custom SSL certificate generated from AWS</li></ol><p>We’ll assume you already have a domain registered somewhere. And you have access to your <a href="https://www.wpbeginner.com/glossary/dns/">DNS settings</a>. But if you don’t have access to <a href="https://www.wpbeginner.com/glossary/dns/">DNS</a>, then it’s alright too, as we will show you how to get registered using email as well.</p><p>To get the SSL Certificate, if you already don’t have one, you can just click the <strong>Request or Import a Certificate with ACM </strong>from the distribution page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IuZltH4OpNk5OiOb6yJV_A.png" /></figure><p>Or you can also directly to the <a href="https://console.aws.amazon.com/acm/home?region=us-east-1#/wizard/"><strong>Request Certificate</strong></a><strong> </strong>page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-sDs4QUpeyJmmZP-cIlIqQ.png" /><figcaption>Request custom SSL Certificate page</figcaption></figure><p>Enter your custom domain name and press <strong>Next.</strong></p><p>Then you will be taken to the <strong>Select validation method </strong>page, where you will get two types of validation method:</p><ol><li><strong>DNS validation: </strong>It&#39;s the most used one. It requires the user to go to the <a href="https://www.wpbeginner.com/glossary/dns/">domain DNS settings</a> page, then adding a new <a href="https://en.wikipedia.org/wiki/CNAME_record"><strong>CNAME</strong> record</a>.</li><li><strong>Email validation: </strong>It uses some pre-configured email address to send you a validation email where you will be asked to verify that you requested the SSL certificate. If you accept that, then it will create an ACM SSL certificate in AWS. The email addresses are: <br>* postmaster@yourdomain.com<br>* hostmaster@yourdomain.com<br>* admin@yourdomain.com<br>* webmaster@yourdomain.com<br>* administrator@yourdomain.com</li></ol><p>We will just briefly walk you through both of the ways just in a bit. But for now, let’s continue by selecting the <strong><em>Email validation</em></strong> option as it is the easy one.</p><p>In the next step, just press <strong>Review</strong> and you will be given a final checkup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i76tvu8UzXFt1GdnPVISgA.png" /><figcaption>Make sure everything is in place</figcaption></figure><p>Now hit <strong>Confirm</strong> and it’s ready to go. AWS will send you an email for the confirmation on the pre-configured email addresses as mentioned before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_MmluRKURVjGl8v7bLV8Q.png" /><figcaption>Email is sent to the shown email addresses</figcaption></figure><p>Until you verify your email or set up the DNS, you will see the verification status as <em>Pending validation</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*owIY8J2Wu3NkIxlnWp1pzw.png" /><figcaption>Waiting for confirmation</figcaption></figure><p>This is how a verification email looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9PKbITf8rAEXx4_Cb6TLDQ.png" /><figcaption>The verification email from AWS</figcaption></figure><p>Just press the <strong>Amazon Certificate Approvals </strong>link or copy and paste the URL on any browser and it will show you the message again. Hit the <strong>I Approve</strong> button and you are all set!</p><p>You can find that on the SSL certificate page as well if you refresh it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*reVewHKhzMm6L7v5v8GhQw.png" /><figcaption>The domain SSL certificate is created</figcaption></figure><blockquote>For some domain/hosting platform, the Email Validation doesn’t work. If you find that the domain is not working, try using the DNS Validation instead of Email Validation. The DNS CNAME record-setting differs for different vendors. So we can’t cover that here.</blockquote><p><strong>DNS validation Process</strong></p><p>In case you selected DNS instead of Email, you will have to follow a different route. In that case, after you <strong>Confirm </strong>the process, you will get this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hxx3mDmIW0GzaPq7j_5GOg.png" /><figcaption>CNAME record credentials</figcaption></figure><p>You will find the credentials you need to set in the domain DNS system as a CNAME record. You can also download that credentials CSV file if you want to do it later or send it to someone who has access to the DNS settings. After the CNAME record is created, it will show the status as <strong><em>issued</em></strong> in the SSL certificate list.</p><p>When setting up the CNAME, you actually will need to set up 2 CNAME records.</p><ol><li>For verifying the custom SSL certificate. In this case, the name and value you will get from the AWS, the image we’ve shown just before.</li><li>For redirecting to the CloudFront when we enter the domain on a browser. The name for this one will be the <em>custom domain name</em> you want to set up for the website (in our case <em>reactaws.apphousebd.com</em>) and the value will be the CloudFront distribution domain name. Keep in mind the <em>custom domain name </em>you set up for as the name, because it will be needed later when setting up the <strong>Alternate Domain Names (CNAMEs) </strong>field.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*cq6CmLJwHjUzEvO2R56Anw.png" /><figcaption>CloudFront distribution domain name</figcaption></figure><p>It may take some time to verify the domain with DNS validation, so wait at least 5–10 mins before trying again.</p><h3>Setting the Custom domain in CloudFront</h3><p>Now for the moment that we are building up the whole thing!</p><p>Go to the CloudFront distribution page and select <em>Edit</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4jtIzdBorMeo_ExTJu5hGg.png" /></figure><ul><li>There in the <strong>Alternate Domain Names (CNAMEs) </strong>field, enter the custom domain name of which you have already created an SSL certificate.</li><li>After that, select the <em>Custom SSL Certificate (example.com) </em>option for <strong>SSL Certificate. </strong>There if you click on the input box, you will find the SSL certificate you created. Select the one with the domain you entered in the previous step.</li><li>Enter <em>index.html</em> in the <strong>Default Root Object </strong>input field</li><li>Keep the other thins as it is.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*pC6jFpLnnU-4vqCDENCWDg.png" /><figcaption>Distribution setting after everything is set up</figcaption></figure><p>Hit <strong>Yes, Edit</strong> and that’s it. Finally, everything is over!!! Just wait until the status of the CloudFront distribution is changed from <strong>In Progress</strong> to <strong>Deployed </strong>and then you can test the website with the custom domain you just set. For us, it’s <a href="https://reactaws.apphousebd.com/"><strong>reactaws.apphouse.com</strong></a>.</p><p>Well, it’s been a long way since the start.🛣️️ But I believe you now have enough knowledge about how to deploy your own or any other person’s React website on AWS. Hope this post helps you in your exciting coding/developer life.😌 Happy coding!👨‍💻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4651983f87e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/craftsmenltd/publishing-a-react-website-on-aws-with-aws-amplify-and-aws-cloudfront-with-custom-domain-part-2-4651983f87e">Publishing a React website on AWS with AWS amplify and AWS CloudFront with Custom Domain (Part 2)</a> was originally published in <a href="https://medium.com/craftsmenltd">Craftsmen — Software Maestros</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Publishing a React website on AWS with AWS amplify and AWS CloudFront with Custom Domain (Part 1)]]></title>
            <link>https://medium.com/craftsmenltd/publishing-a-react-website-on-aws-with-aws-amplify-and-aws-cloudfront-with-custom-domain-part-1-eb81d3d95b2d?source=rss-ce042d8705ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb81d3d95b2d</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[aws-amplify]]></category>
            <category><![CDATA[aws-cloudfront]]></category>
            <dc:creator><![CDATA[Asif Imtiaz Shaafi]]></dc:creator>
            <pubDate>Thu, 24 Dec 2020 12:30:54 GMT</pubDate>
            <atom:updated>2021-03-09T11:18:34.999Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="React with AWS Amplify and AWS CloudFront" src="https://cdn-images-1.medium.com/max/781/1*pSAfVZo9hjcNF36_XjIa1A.png" /><figcaption>React with AWS Amplify and CloudFront</figcaption></figure><p>In the modern world, we are very much dependent on the internet. And one of the best ways to reach a person is via a website. It’s very easy to build websites using <a href="https://reactjs.org/">React</a>. But most of the time, people find it hard to deploy the website on a reliable service where there is almost zero downtime and which is very cost-effective. AWS can provide us those features. Anyone can deploy any react project on AWS and publish a website by following very simple steps. So let’s get started 😄…</p><blockquote>Part 1 covers the React project creation and AWS Amplify part.</blockquote><blockquote><a href="http://bit.ly/37KdERW">Part 2 covers the CloudFront configuration and custom domain setup part.</a></blockquote><h3><strong>AWS Amplify</strong></h3><p>AWS amplify is mainly a set of features that can be used to deploy any front-end based application or projects on AWS. It’s easy and convenient to use and it has all the features integrated into it that will help you to implement different AWS services into your application and grow your project over time. To find out more about it, check out their <a href="https://aws.amazon.com/amplify/">official website</a>.</p><h3>AWS CloudFront</h3><p>AWS CloudFront is a CDN (content delivery network) service that helps you to deliver your content that is data, video, image, etc to all the corners of the world with the lowest latency. In simple words, it’s a path between AWS content and the open wide world. To learn more, visit the <a href="https://aws.amazon.com/cloudfront/">AWS CloudFront webpage</a>.</p><h3>Before You Begin 👀…</h3><p>This post is not for those who are absolutely beginner. This is not a React teaching post. This post will assume that you already know how to create React projects and have a basic understanding of it. Also, it’s not an AWS basic tutorial either. It will not teach you how AWS amplify works or how CloudFront works. But it will show you the minimum configurations and steps you need to follow the process and publish a React website with a custom domain. As this post uses AWS, we will assume that you already have an AWS account or have access to an account, as you will need to use your credentials for AWS Amplify and will need to go to AWS console and configure AWS CloudFront. If you still think this post can help you, then let’s get into it.</p><h4>Requirements</h4><p>Here are the environments that are used when creating the post. You can match them if you want. But it’s not mandatory.</p><p><em>Node Js version</em>: <a href="https://nodejs.org/download/release/v12.18.3/"><strong><em>v12.18.3</em></strong></a><em> (check via </em>node —-version)<br><em>NPM version</em>: <strong>6.14.6</strong> <em>(</em>check via npm —-version)<br><em>React version</em>: <strong>17.0.1</strong><br><em>Text Editor / </em><a href="https://www.codecademy.com/articles/what-is-an-ide"><em>IDE</em></a>: <a href="https://code.visualstudio.com/">Visual Studio Code</a><br><em>CLI</em>: Git Bash</p><h4>Source Code</h4><p>You can get all the codes used in this project in this <a href="https://github.com/AsifShaafi/react-amplify-cloudfront"><strong>GitHub Repository</strong></a>.</p><h3>Project Introduction</h3><p>We will be creating a simple website where a user will find an input box and when the user enters his/her name in it, it will show a welcome message to the user.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F5uip8g5KnZI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D5uip8g5KnZI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F5uip8g5KnZI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd7b0c52c345e12f961fb96e2ff9a9bc/href">https://medium.com/media/fd7b0c52c345e12f961fb96e2ff9a9bc/href</a></iframe><p>We will use <strong>AWS Amplify</strong> to push/publish the website on AWS where the <a href="https://aws.amazon.com/s3/"><strong>AWS S3</strong></a><strong> </strong>bucket will be used to hold the React project files. The bucket will be public so that it can be used as hosting storage for the website. After that, we will use <strong>AWS CloudFront</strong> to add a domain layer so that we don’t have to use the S3 bucket domain name to see the website. Finally, we will add a <strong>Custom domain</strong> in the <strong>CloudFront</strong> which will show users the website content whenever the custom domain is called.</p><p>As there is a lot to cover, this post is divided into two parts. In the first part, we will create the React project and publish it on AWS. And on the second one, we will configure the CloudFront to access the website with a custom domain.</p><p>Let’s start to make our hands dirty 😉…</p><h4>Creating a React Project</h4><p>We will start off by creating a new React project which we will publish later. To create a React project, go to your desired folder, and then open any <a href="https://en.wikipedia.org/wiki/Command-line_interface">CLI</a> and run:</p><pre>$  npx create-react-app react-amplify-cloudfront</pre><p>This will create a new folder called <strong>react-amplify-cloudfront</strong> in the working directory. Open that directory in any <em>text editor or IDE</em> of your choice. As mentioned before, we will be using <em>Visual Studio Code</em> as the IDE. If you are doing so as well, you can write the following in the CLI to open it in <em>VS Code.</em></p><pre>$  cd react-amplify-cloudfront &amp;&amp; code .</pre><p>There you will find something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*Qzp2T0Qb9nDJ0MwFMQPnQA.png" /><figcaption>React project folder structure</figcaption></figure><p>Let’s run npm start on the present directory. This will open up a browser window and you will see the default React home page.</p><p>Now, we will replace the <strong>App.js</strong> file with the following code snippet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/72dc1e12bad183f935658a1c556a58a6/href">https://medium.com/media/72dc1e12bad183f935658a1c556a58a6/href</a></iframe><p>And also, we will replace the content of <strong>App.css</strong> file with the following as well.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e8d918882d0216352a4d596fe262a2a/href">https://medium.com/media/6e8d918882d0216352a4d596fe262a2a/href</a></iframe><p>If you do everything right, you will be able to see this screen on your browser:</p><figure><img alt="React home page after updating App.js and App.css" src="https://cdn-images-1.medium.com/max/1024/1*izuAQJbhcaG3rL7Ym0ex1Q.png" /><figcaption>React home page after modification</figcaption></figure><p>Perfect!! 🥳😎 We can now move to AWS Amplify 😀…</p><h4>Setting up AWS Credentials</h4><p>Before adding AWS Amplify into the project, we first need to set the AWS user credentials into the system. You can find how to set up the basic AWS user credentials <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html">here</a>.</p><h4>Install AWS Amplify</h4><p>First, we need to install the AWS Amplify into our system. We will use Node to install the <a href="https://www.npmjs.com/package/@aws-amplify/cli">AWS Amplify CLI NPM package</a>. To install it globally, run:</p><pre>$  npm i -g @aws-amplify/cli</pre><p>With this, we can use the amplify command anywhere.</p><p>Update: I forgot to add the -g tag when installing the <em>aws-amplify/cli </em>library. Thanks to <a href="https://medium.com/u/a59ac5b07752">Ophir Tal</a> for helping me to find this error.</p><figure><img alt="Amplify npm library version check" src="https://cdn-images-1.medium.com/max/247/1*L4UYZp9K3gvIsN9ukKQivA.png" /><figcaption>Amplify version check</figcaption></figure><p>To check if it’s installed successfully, run: <br>amplify —-version . This should return the installed version name.</p><h4>Initialize the Project with AWS Amplify</h4><p>Now, we need to initialize the React project to work with AWS Amplify. To do that, open a CLI in the project directory, and run:</p><pre>$  amplify init</pre><p>This will start the process and ask for some information.</p><ul><li>First, it will ask for the project name which will be used for the AWS Amplify process. <em>This project name should be between 3 and 20 characters and alphanumeric.</em></li><li>Then will ask about the environment. The environment name is <em>dev</em> by default, and we will keep that one.</li><li>Select the IDE you are using in the next step.</li><li>The application type is <em>javascript</em> in our case, as we are using React.</li><li>The framework is <em>React </em>(in case you are wondering…😜 )</li><li>Finally, just press enter for the last few steps. (That’s easy enough, right?🤔 )</li></ul><p>After everything is done, the AWS Amplify will create and configure all the necessary things to publish the React project on the AWS S3 bucket.</p><figure><img alt="AWS Amplify initialization" src="https://cdn-images-1.medium.com/max/1024/1*5k_tvV--JHrSEF5JhNvYHQ.jpeg" /><figcaption>AWS Amplify initialization</figcaption></figure><p>At the end of the process, you will find some useful commands as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9lZB_Oy02E22I_tcVdpwiA.png" /><figcaption>AWS Amplify commands</figcaption></figure><h4>Publish using AWS Amplify</h4><p>Now that the project has been initialized with AWS Amplify, we can use it to publish the project on AWS S3. But before that, we need to tell amplify that we want to publish the project for hosting. Otherwise, it will not upload the files on the S3 bucket.</p><p>To add the hosting configuration on AWS amplify, run:</p><pre>$  amplify add hosting</pre><p>Just as amplify initialization, this command will take you through some configuration questions. Let’s walk through them.</p><ul><li>First, it will ask you for the plugin module to execute. As said before, we will be using the AWS S3 and CloudFront for the hosting and domain setup, we will select that one. So select: <em>Amazon CloudFront and S3.</em></li><li>Second, it will ask for the environment, and for this one, we will select <em>dev</em>. We don’t need the <em>prod</em> (which will configure the CloudFront as well) right now, as we will set up the CloudFront later ourselves.</li><li>You can just select the default values for the rest of the config and press Enter for each one.</li></ul><p>And we are done with it. Now the only thing remaining is to publish the added category on AWS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*KBvNKCe6aFyBkao_FpkJ-A.png" /><figcaption>Amplify Hosting added successfully</figcaption></figure><p>To publish the newly added hosting category and upload the files on the AWS S3 bucket, just run in the CLI:</p><pre>$  amplify publish</pre><p>It will ask you to confirm all the configs, just <em>press enter to continue</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*z8laIvYMhhdPGrwSiUXCnQ.png" /><figcaption>Publishing project on AWS S3</figcaption></figure><p>This may take several minutes depending on your internet connection speed. But when it’s published and uploaded successfully, it will open up a window in your browser and you will find the React website up and running!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*vloOSc1PPaBQn_hxew32XA.png" /><figcaption>URL of the published website</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vkYTRnZ-IyG7Dr6AH2zJ7A.png" /></figure><p>🥳 That it!! 🥳 We have uploaded the React project on AWS and we can use the URL to view the project from any browser! 🌟</p><p>That’s all for now. Hope this post has helped you to understand how to use <em>AWS Amplify</em> to publish React project on AWS. In part 2, we will set up the <em>AWS CloudFront</em> to use <em>Custom Domain</em> to access the published website. Till then be safe and keep coding!! 👨‍💻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb81d3d95b2d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/craftsmenltd/publishing-a-react-website-on-aws-with-aws-amplify-and-aws-cloudfront-with-custom-domain-part-1-eb81d3d95b2d">Publishing a React website on AWS with AWS amplify and AWS CloudFront with Custom Domain (Part 1)</a> was originally published in <a href="https://medium.com/craftsmenltd">Craftsmen — Software Maestros</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up a NodeJs/TypeScript CI/CD Pipeline for AWS Lambda Using GitHub Action and Serverless]]></title>
            <link>https://medium.com/craftsmenltd/setting-up-a-nodejs-typescript-ci-cd-pipeline-for-aws-lambda-using-github-action-and-serverless-81f718036b4?source=rss-ce042d8705ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/81f718036b4</guid>
            <category><![CDATA[aws-lambda-functions]]></category>
            <category><![CDATA[serverless-framework]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[pipeline]]></category>
            <dc:creator><![CDATA[Asif Imtiaz Shaafi]]></dc:creator>
            <pubDate>Mon, 14 Sep 2020 17:29:15 GMT</pubDate>
            <atom:updated>2020-09-15T05:06:24.991Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tAiyRD1MJppOUuECm2gqRg.jpeg" /><figcaption>CI/CD Pipeline [Photo by <a href="https://unsplash.com/@jjying?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">JJ Ying</a> on <a href="https://unsplash.com/@jjying?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a>]</figcaption></figure><h3>Introduction</h3><p>When working with an <a href="https://aws.amazon.com/lambda/">AWS Lambda</a> project, it’s common to change your code locally, and then upload it on AWS daily or at least a weekly basis. It’s very much true for projects that are medium or large and where new features and bugfixes are constantly being added. A CI/CD pipeline can help a lot in these cases, as the developers don’t have to push the code on AWS manually and don’t have to worry about stuff related to pushing. They can just do their work and forget about the unnecessary things. And it’s also very easy to create such a pipeline just using <a href="https://github.com/features/actions">GitHub Actions</a> and <a href="https://www.serverless.com/">Serverless Framework</a>.</p><p>Today we are going to create a pipeline to automate the deploy of a NodeJs project using GitHub Action and Serverless. I’m going to use Node as the runtime of the AWS Lambda and will be using <a href="https://www.typescriptlang.org/">TypeScript</a> to write the lambda.</p><h3>Source Code</h3><p>You can get all the codes used in this project in this <a href="https://github.com/AsifShaafi/aws_lambda_github_pipeline"><strong>GitHub Repository</strong></a>. If you want, you can skip the post and get the codes and play around with them however you like.</p><h3>Requirements</h3><p>Before getting started with the post, you must have some knowledge on <a href="https://www.serverless.com/">Serverless Framework</a> which is used for deploying AWS Lambda functions. It also helps to configure the AWS services so that we don’t have to do them manually from the AWS console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TChqNJPWqVTYCGOc3RNXlA.png" /><figcaption>Serverless logo</figcaption></figure><p>But if you aren’t familiar with it and want to get started, then you follow this <a href="https://serverless.com/framework/docs/providers/aws/guide/quick-start/">quick-start guide for the Serverless Framework</a>.</p><p>Before following this tutorial, make sure you have Serverless Framework installed and configured on your working environment. Also, you need to have a working <a href="https://github.com/">GitHub</a> account. If you don’t have any then create a GitHub account from <a href="https://github.com/join">here</a>.</p><p>Now let’s get going with the tutorial…</p><h3>Create AWS Lambda project with Serverless</h3><p>First, we need to create a TypeScript based AWS Lambda project using the Serverless Framework CLI. Open up any terminal and enter the following command:</p><pre>serverless create --template aws-nodejs-typescript --path &lt;your-folder-name&gt;</pre><blockquote>Here, the <em>--template</em> flag will generate some files for the given template. You can get more templates from <a href="https://www.serverless.com/framework/docs/providers/aws/cli-reference/create#available-templates">here</a>. For more info on <em>serverless create</em> command, check <a href="https://www.serverless.com/framework/docs/providers/aws/cli-reference/create/">here</a>.</blockquote><p>The above command will create a new directory with the name you gave in &lt;your-folder-name&gt; and create some new files like <em>handler.ts, </em><em>serverless.ts, </em><em>package.json, </em><em>tsconfig.json, </em><em>webpack.config.js</em>. The <em>handler.ts </em>file contains some boiler code:</p><p>And the <em>serverless.ts</em> file contains the configuration for deploying the function on AWS. If want to know what can be configured with the file, take a look <a href="https://serverless.com/framework/docs/providers/aws/guide/serverless.yml/">here</a>.</p><p>Now go to the directory that was created and open cmd pointing the directory and run the following command:</p><pre>npm install</pre><p>This will install all necessary npm libraries.</p><h3>Create Serverless Deploy Script</h3><p>In the project directory, we need to configure the <em>package.json</em> file a bit to be able to deploy the lambda project on AWS Lambda directly using the <em>npm</em> script command. Here is the code after adding the <em>npm</em> script:</p><p>Note: Please make sure that the <a href="https://www.npmjs.com/package/serverless"><strong><em>serverless</em></strong> npm library</a> is present in the <em>package.json </em>file. If not then you can add it using this command:</p><pre>npm i serverless -D</pre><p>Now it’s time to deploy the code!!</p><h3>Test Deploy Manually</h3><p>To test that the <em>npm</em> script is working as well as the main code, let’s deploy the lambda project manually. For that, go to the root directory, open any terminal, and execute:</p><pre>npm run-script deploy</pre><p>If everything is working as expected, then you will see this message on your terminal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*lx_LEB2bWBEirQzjmhMHWA.png" /><figcaption>Serverless deploy response</figcaption></figure><p>And if you go to the address given in the <em>endpoints</em> section, we will see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*XH9eV89Vwbkj0KNzVI07Qw.png" /></figure><p>If all of these went well, then we are good to create the GitHub Action and create the pipeline.</p><h3>Create GitHub Action</h3><p>For making GitHub Action work, we have to put the workflow file into a specific folder in the desired project directory. We will create the folders and the workflow/action file using some simple steps:</p><ol><li>In the root directory of the project, create a <strong>folder</strong> named <strong><em>.github</em></strong></li><li>Go the the <strong><em>.github </em></strong>folder and create another <strong>folder</strong> named <strong><em>workflows</em></strong></li><li>Go to the newly created folder and create a new <strong>file</strong> named <em>aws_lambda_deploy.yaml </em>and copy-paste the following code snippet:</li></ol><p>This code will be triggered when the action workflow when you <strong><em>push </em></strong>any code on the <strong><em>master</em></strong> branch on GitHub. You can learn more options for the trigger from <a href="https://docs.github.com/en/actions/reference/events-that-trigger-workflows">here</a>.</p><h3>Add AWS Secrets</h3><p>To make the workflow work as intended, we need to add the AWS User <em>access key</em> and <em>secret access key </em>and set them inAWS_ACCESS_KEY_IDand AWS_SECRET_ACCESS_KEY respectively. We will set this up now.</p><h4>Get the User Secrets from AWS Console</h4><p>For getting the access key and secret access key, go to <a href="https://console.aws.amazon.com/iam/home">IAM</a> service in the <a href="https://console.aws.amazon.com/console/home">AWS Management Console</a>. If you are not sure how to get them or need to create a new role, check <a href="https://serverless-stack.com/chapters/create-an-iam-user.html"><strong>this article</strong></a>.</p><h4>Set the User Secrets in GitHub</h4><p>To set the user secrets, use the following steps:</p><ol><li>Open your GitHub repository on any browser, then click on the <em>“Settings”</em> tab.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wB3MFSdf32YW2RWZNSx-AA.jpeg" /><figcaption>Select the <strong><em>“Settings”</em></strong> tab</figcaption></figure><p>2. Then on the left navigation panel, select <em>“Secrets”</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O3wjpq-WnikmzTL_vkZypQ.jpeg" /></figure><p>3. In the “Secrets” page, press the <em>“New Secret”</em> button on the top right corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*26GireaHEorckenCFudmNQ.jpeg" /></figure><p>4. On the new page, put AWS_ACCESS_KEY_ID in the <em>“Name” </em>filed and put the <em>access key</em> value from the AWS IAM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmI4xBXwqlb-jHY1O3ec0w.jpeg" /></figure><p>5. Repeat the 3rd step for adding AWS_SECRET_ACCESS_KEY secret.</p><h3>Sit Back and Enjoy!</h3><p>And we are done! If you have made this far, that means you have successfully created a pipeline to deploy your AWS Lambda project on AWS! Now it’s time to see it in action. Make some changes in your <em>handler.ts </em>file and push it on the <strong><em>master</em></strong> branch. I made the following change:</p><pre>import &quot;source-map-support/register&quot;;</pre><pre>import { APIGatewayProxyHandler } from &quot;aws-lambda&quot;;</pre><pre>export const hello: APIGatewayProxyHandler = async (event, _context) =&gt; {</pre><pre>return {</pre><pre>statusCode: 200,</pre><pre>body: JSON.stringify(</pre><pre>{</pre><pre>message:</pre><pre>&quot;This code is deployed directly from the CI/CD pipeline using GitHub Action and Serverless!&quot;,</pre><pre>httpMethod: event.httpMethod,</pre><pre>},</pre><pre>null,</pre><pre>2</pre><pre>),</pre><pre>};</pre><pre>};</pre><p>After you push the code, you can track the pipeline by going to the <em>“Actions”</em> tab on the GitHub repository and selecting the latest workflow. If you see a green checkmark (✔️) beside the workflow, that means the workflow was successfully executed and you have deployed your code without doing any extra steps!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ujhx9ib2RZrxsfD3IqBh2A.jpeg" /><figcaption>GitHub Action workflow executed successfully</figcaption></figure><p>You can also verify that by going to the URL you got before when we deployed the code manually. Here is mine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*4wysLq6BJx3gxQcSE8altA.jpeg" /></figure><p>This is all you need to create a basic CI/CD pipeline to deploy on AWS Lambda. You can also add code unit testing, lint checking, and various other things by modifying the GitHub Action workflow according to your needs, but this post is just to get you started.</p><p>Hope this will help you with your developer journey. Happy coding! 😃</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81f718036b4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/craftsmenltd/setting-up-a-nodejs-typescript-ci-cd-pipeline-for-aws-lambda-using-github-action-and-serverless-81f718036b4">Setting Up a NodeJs/TypeScript CI/CD Pipeline for AWS Lambda Using GitHub Action and Serverless</a> was originally published in <a href="https://medium.com/craftsmenltd">Craftsmen — Software Maestros</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connecting with Kaltura from NodeJs using Kaltura TypeScript Client]]></title>
            <link>https://medium.com/craftsmenltd/kaltura-video-upload-from-nodejs-using-kaltura-typescript-client-b0d69f6df7d6?source=rss-ce042d8705ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0d69f6df7d6</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[kaltura]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Asif Imtiaz Shaafi]]></dc:creator>
            <pubDate>Sun, 13 Sep 2020 11:24:13 GMT</pubDate>
            <atom:updated>2020-09-14T17:41:47.782Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*8mWbb7JlJttzYNRF0fFyqA.png" /><figcaption>Kaltura and TypeScript</figcaption></figure><h3>Introduction</h3><p>Recently when I was working on a project, I found myself looking for a better way to upload a video on <a href="https://corp.kaltura.com/">Kaltura</a> from a NodeJs project. Of course, there is a <a href="https://www.npmjs.com/package/kaltura-client">Kaltura npm library</a> that can be used to upload videos and do other things on Kaltura, but it didn’t work out for us, so we switched to <a href="https://github.com/kaltura/KalturaGeneratedAPIClientsTypescript">Kaltura TypeScript client</a>.</p><h3>Motivation</h3><p>Our main objective was to be able to create a media entry on Kaltura and upload a video on that entry using a URL. And while creating the media entry, we will provide some video metadata like title, description, etc. And these metadata may contain some Danish characters.</p><p>We are using <a href="https://www.typescriptlang.org/">TypeScript</a> as our coding language, so I was looking for a typed Kaltura client library to use for our objective. But unfortunately at that time, we didn’t find the Kaltura TypeScript client library, so we made work with the npm library. It was doing fine until we found that if we try to create an entry that contains any Danish characters, it fails in the code giving some errors. At first, we thought it was a problem with Kaltura API, but after some debugging and some chat with Kaltura support, we realized that the error was in the npm library. So I started looking for an alternative and that is when I found the <a href="https://github.com/kaltura/KalturaGeneratedAPIClientsTypescript">Kaltura TypeScript client</a> on the <a href="https://developer.kaltura.com/api-docs/Client_Libraries">Kaltura native libraries</a> page.</p><h3>Source code</h3><blockquote>You can get the full project code in this <a href="https://github.com/AsifShaafi/kaltura_typescript_test">GitHub project</a>. The initial project code is in the <strong><em>master</em></strong> branch and a full working code that connects to Kaltura lies in the <strong><em>develop</em></strong> branch. You can download the code and use it as a reference to get going.</blockquote><h3>Code Setup</h3><p>For this demonstration, I’ll create a new NodeJs project. Initially, the project structure is like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*sHpBBp2CIAXMF35dtfxCUA.png" /><figcaption>Kaltura TypeScript testing project initial state</figcaption></figure><p>You can grab the project from the <a href="https://github.com/AsifShaafi/kaltura_typescript_test">GitHub repo</a>. The <em>master </em>branch contains the initial project structure shown in the image above.</p><h3>Adding the Kaltura Library</h3><p>To use the <a href="https://github.com/kaltura/KalturaGeneratedAPIClientsTypescript">Kaltura TypeScript client</a>, first, clone the library from <a href="https://github.com/kaltura/KalturaGeneratedAPIClientsTypescript">GitHub</a>. After that go to the project directory and run the following commands:</p><pre>$ npm install<br>$ npm run deploy</pre><p>This will create a folder in the working directory named <strong><em>dist</em></strong>, where the main TypeScript library can be found, which is named like: <br><strong><em>kaltura-typescript-client-&lt;version_name&gt;.tgz</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*zkoIzu7N51M_orDTXNXZoA.png" /><figcaption>Generated Kaltura TypeScript library (Red marked)</figcaption></figure><p>Now we need to place this file in the project that we created before. I’ll put the file in the <em>lib </em>directory of the project. For simplicity, I’ll rename the file to <strong><em>kaltura-typescript-client-7.0.1.tgz</em></strong>. But you can leave it as it is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*WOf-uFXCKp8ci1-sjJzH6A.png" /><figcaption>Kaltura TypeScript library added and renamed</figcaption></figure><p>Now open the <em>package.json</em> file and add the following into the “<em>dependencies</em>” block:</p><pre>&quot;kaltura-typescript-client&quot;: &quot;file:lib/kaltura-typescript-client-7.0.1.tgz&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*a3Uud5mnhWQCV8mTw9i08w.png" /><figcaption>Add the library located inside the dependencies block in the <strong>package.json</strong> file</figcaption></figure><p>After that just open any terminal, go to the project root and execute:</p><pre>$ npm install</pre><p>That’s it, you have successfully added the Kaltura TypeScript library into your NodeJs project. All that’s left is to apply it in code and connect to Kaltura and do whatever you want to do.</p><h3>Connecting to Kaltura</h3><p>To test that our library integration is working, it’s best to connect to the Kaltura developer account and get the session token.</p><p>First, let&#39;s add a new file named kalturaService.ts in the <em>src &gt; util</em> folder. In this file, we will add the necessary methods to connect to the <a href="https://developer.kaltura.com/api-docs/Overview"><strong>Kaltura API</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*CoyQ8bKksmhCgBEAWU0xWQ.png" /></figure><p>Paste the following code into the kalturaService.ts file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/baae4778ba421ad4564576fc32d7be3a/href">https://medium.com/media/baae4778ba421ad4564576fc32d7be3a/href</a></iframe><p>Here, give extra attention in the following line in the code:</p><pre>global.XMLHttpRequest = require(&quot;xhr2&quot;);</pre><p>This line set’s the XMLHttpRequest from <a href="https://www.npmjs.com/package/xhr2">xhr2 npm library</a>, because in the Kaltura TypeScript library, it uses XMLHttpRequest to connect to <a href="https://developer.kaltura.com/api-docs/Overview"><strong>Kaltura API</strong></a>. If you don’t add this line you might get an error: <strong><em>ReferenceError: XMLHttpRequest is not defined </em></strong>. To avoid that, add <a href="https://www.npmjs.com/package/xhr2">xhr2 npm library</a> by running the following command on the terminal from the project root. And while we are at it, we will be needing another npm library, <a href="https://www.npmjs.com/package/dotenv"><em>dotenv</em></a>which will be used to get the Kaltura account credentials from the .env file, which we will create just after a little bit.</p><pre>$ npm install -D xhr2 dotenv</pre><p>Now it’s time for using the file we just created to get the session token of Kaltura. Copy the following code and paste it into the index.ts file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64d94be5c9f08f7c31858573135413a0/href">https://medium.com/media/64d94be5c9f08f7c31858573135413a0/href</a></iframe><p>Here we are getting the <em>adminSecret, userSecret, partnerId</em> that we need to connect to the Kaltura API. You can find these credential info by following these steps:</p><ol><li>Login to the <a href="https://kmc.kaltura.com/index.php/kmcng/login">Kaltura management console</a>. If you don’t have an account, just create a new one from <a href="https://corp.kaltura.com/video-content-management-system/free-trial/">here</a>.</li><li>Click the <em>Settings</em> icon or <a href="https://kmc.kaltura.com/index.php/kmcng/settings/integrationSettings">click here</a> to directly go to the settings page.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5QGmM7D3NLXCbqsp3Gm6ww.png" /></figure><p>3. Select the <em>INTEGRATION</em><strong><em> </em></strong>tab, or <a href="https://kmc.kaltura.com/index.php/kmcng/settings/integrationSettings">click here</a> to directly open the page. There you will find all the necessary info needed for this testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*TGxh3EnFEQ4UuN0FibDvPQ.png" /><figcaption>Kaltura Integration settings page where all necessary credentials are placed.</figcaption></figure><p>Now just copy the <em>.env.example</em> file from the <a href="https://github.com/AsifShaafi/kaltura_typescript_test">GitHub project</a> or copy the content of the file from <a href="https://github.com/AsifShaafi/kaltura_typescript_test/blob/master/.env.example">here</a> and then create a new file named <em>.env</em> and paste the copied code in the <em>.env</em> file.</p><p>That’s it, now you are ready to run the code! Just hit npm start from the terminal or cmd and you should get a success message: “<em>Successfully got the Kaltura session”</em> with the Kaltura session token! You now do whatever you want on Kaltura using this TypeScript library. To get to know what you can do and how to do it, visit the <a href="https://developer.kaltura.com/api-docs/Overview"><strong>Kaltura API documentation</strong></a>, where you will also find the code snippet for your desired work.</p><p>That’s all for now. I hope this will help you to get up and running with the Kaltura TypeScript library. Happy coding!!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FMdA16VIoXKKxNE8Stk%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FMdA16VIoXKKxNE8Stk%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FMdA16VIoXKKxNE8Stk%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/f21ad169011db1cb6b384e677caf5661/href">https://medium.com/media/f21ad169011db1cb6b384e677caf5661/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0d69f6df7d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/craftsmenltd/kaltura-video-upload-from-nodejs-using-kaltura-typescript-client-b0d69f6df7d6">Connecting with Kaltura from NodeJs using Kaltura TypeScript Client</a> was originally published in <a href="https://medium.com/craftsmenltd">Craftsmen — Software Maestros</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>