<?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 Zimam Sayeed on Medium]]></title>
        <description><![CDATA[Stories by Zimam Sayeed on Medium]]></description>
        <link>https://medium.com/@zimamsayeed?source=rss-7c6b9c74b70f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ItCLAESMuhBiktOA.</url>
            <title>Stories by Zimam Sayeed on Medium</title>
            <link>https://medium.com/@zimamsayeed?source=rss-7c6b9c74b70f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 09:17:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zimamsayeed/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[Writing NodeJS APIs for AWS Lambda Locally]]></title>
            <link>https://medium.com/@zimamsayeed/writing-nodejs-apis-for-aws-lambda-locally-9514a3b76799?source=rss-7c6b9c74b70f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9514a3b76799</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[aws-api-gateway]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[version-control]]></category>
            <dc:creator><![CDATA[Zimam Sayeed]]></dc:creator>
            <pubDate>Mon, 10 Aug 2020 06:06:43 GMT</pubDate>
            <atom:updated>2020-10-20T03:10:30.068Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*GvQD3yb7EkyEyBN1vkKEyQ.png" /></figure><p>In this article we will see how to write APIs in NodeJS locally on our system and deploy it to AWS Lambda. This technique can be used if we want to include version control on our code written in Lambda console for the APIs.</p><p><strong>Folder structure:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*Jbc14W9eO0tBax6hUd5CSA.png" /></figure><p><strong>Steps to setup the project:</strong></p><ol><li>Let us start with setting up a new node project on Desktop, let’s say.</li></ol><pre><strong>$ cd Desktop</strong></pre><pre><strong>$ mkdir scanAPI &amp;&amp; cd scanAPI</strong></pre><pre><strong>$ npm init</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*VydqWo2WvxlMTnQa" /></figure><p>2. Install <strong>aws-serverless-express</strong> package in the scanAPI folder:</p><pre><strong>$ npm install aws-serverless-express</strong></pre><p>3. Create <strong>index.js</strong> file in the scanAPI folder and write the following code in that file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4fadc657683024f39aaf6e3b8fb5f66/href">https://medium.com/media/a4fadc657683024f39aaf6e3b8fb5f66/href</a></iframe><p>4. As you can see in the third line, <strong>_Entry.js</strong> is imported from the <strong>main-app</strong> folder. So, create a folder in scanAPI folder named <strong>main-app</strong></p><p>5. Go into the <strong>main-app</strong> folder and make a new node project:</p><pre><strong>$ cd main-app</strong></pre><pre><strong>$ npm init</strong></pre><p>Make sure your entry point is <strong>_Entry.js</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O2XlqhJtDoJlAvh6" /></figure><p>6. Install the packages needed to run a node application and make the APIs:</p><pre><strong>$ npm install express body-parser cors morgan</strong></pre><p>7. Create a new file in <strong>main-app</strong> named <strong>_Entry.js </strong>and write the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfc169dff935a71ed52142c8225c81fa/href">https://medium.com/media/dfc169dff935a71ed52142c8225c81fa/href</a></iframe><p>8. To run the app locally, run the following command in the <strong>main-app</strong> folder:</p><p><strong>In MacOS / Linux OS:</strong></p><pre><strong>$ NODE_ENV=dev node _Entry.js</strong></pre><p><strong>In Windows:</strong></p><pre><strong>$env:NODE_ENV=”dev”</strong></pre><pre><strong>node _Entry.js</strong></pre><p>9. In the browser, navigate to <a href="http://localhost:3001/"><strong>http://localhost:3001/</strong></a> and you should see the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jFc-B1BqDq4vwTv5" /></figure><p>To run the whole code written in node application without having to change anything we can deploy this application on lambda in the following way:</p><ul><li>Create an empty lambda function from the AWS console. Let’s say you created a function with the name <strong>scanapi-lambda</strong></li><li>From your terminal, navigate to the <strong>scanAPI</strong> folder. If you are in main-app navigate one folder back:</li></ul><pre><strong>$ cd ..</strong></pre><ul><li>Now you are in the <strong>scanAPI</strong> folder. Run the following script to upload your node application on lambda without having to change any code:</li></ul><p><strong><em>NOTE:</em></strong><em> You should have AWS CLI installed and configured to the same region as that of your lambda for this command to work in your terminal.</em></p><pre><strong>$ FIRST_ARGUMENT=”$scanapi-lambda”</strong></pre><pre><strong>$ echo “deploying $FIRST_ARGUMENT…”</strong></pre><pre><strong>$ zip -r function.zip *</strong></pre><pre><strong>$ aws lambda update-function-code $FIRST_ARGUMENT — zip-file fileb://function.zip</strong></pre><pre><strong>$ rm function.zip</strong></pre><pre><strong>$ echo “$FIRST_ARGUMENT successfully deployed.”</strong></pre><p>Running the above command should deploy the lambda on the AWS. To hit the API endpoints in Lambda you can create an API gateway and configure it to <strong>scanapi-lambda </strong>for the APIs to work as it would locally.</p><p>This is it for this article. If you guys need more information or a detailed article on how to join this lambda with API gateway, comment below and I shall get back with another article about it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9514a3b76799" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>