<?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 Shweta Pawar on Medium]]></title>
        <description><![CDATA[Stories by Shweta Pawar on Medium]]></description>
        <link>https://medium.com/@shweta.pawar_93580?source=rss-6e7f67220a9c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ykZd8h8Z6NxJa-GUY7bZew.jpeg</url>
            <title>Stories by Shweta Pawar on Medium</title>
            <link>https://medium.com/@shweta.pawar_93580?source=rss-6e7f67220a9c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:43:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shweta.pawar_93580/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[jsPDF to Export SVG Image to PDF Using html2canvas Library in Browser Using Javascript]]></title>
            <link>https://medium.com/@shweta.pawar_93580/jspdf-to-export-svg-image-to-pdf-using-html2canvas-library-in-browser-using-javascript-83da1fccf843?source=rss-6e7f67220a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/83da1fccf843</guid>
            <dc:creator><![CDATA[Shweta Pawar]]></dc:creator>
            <pubDate>Thu, 23 Feb 2023 11:33:08 GMT</pubDate>
            <atom:updated>2023-02-23T11:33:08.750Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*QZyDnR_XbOITEDiFVFLL8w.png" /></figure><p>To plot graphs, images, charts, or any screenshots of web pages or parts of it into PDF then we can use <a href="https://html2canvas.hertzen.com/documentation">html2canvas</a>. By using html2canvas, we can take “screenshots” of it and upload them into PDF.</p><p>Now let&#39;s directly jump into the code without wasting time 😉</p><p>First, we will create an HTML file and JS file</p><h4>➤ <strong>graph.html</strong> &lt;HTML file name&gt;</h4><pre>&lt;html&gt;<br><br>&lt;head&gt;<br>    &lt;script type=&quot;text/javascript&quot; src=&quot;https://code.jquery.com/jquery-1.7.1.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;script src=&quot;jspdf.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br>    &lt;script src=&quot;jspdf.plugin.autotable.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br><br>    &lt;style&gt;<br>        table,<br>        th,<br>        td {<br>            border: 1px solid black;<br>        }<br>    &lt;/style&gt;<br><br>&lt;body&gt;<br>    &lt;!-- &lt;button id=&quot;exportButton&quot; type=&quot;button&quot;&gt;Export as PDF&lt;/button&gt;<br>    &lt;div id=&quot;chartsContainer&quot;&gt;<br>        &lt;div id=&quot;chartContainer1&quot; style=&quot;height: 300px; width: 100%;&quot;&gt;&lt;/div&gt;<br>        &lt;div id=&quot;chartContainer2&quot; style=&quot;height: 300px; width: 100%;&quot;&gt;&lt;/div&gt;<br>    &lt;/div&gt; --&gt;<br>    &lt;button id=&quot;exportButton&quot; type=&quot;button&quot;&gt;Export as PDF&lt;/button&gt;<br>    &lt;h3&gt;Student Table&lt;/h3&gt;<br>    &lt;div&gt;<br>        &lt;table id=&quot;table&quot; class=&quot;display&quot; style=&quot;width:100%&quot;&gt;<br>            &lt;thead&gt;<br>                &lt;tr&gt;<br>                    &lt;th&gt;Name&lt;/th&gt;<br>                    &lt;th&gt;Email&lt;/th&gt;<br>                    &lt;th&gt;Address&lt;/th&gt;<br>                &lt;/tr&gt;<br>            &lt;/thead&gt;<br>            &lt;tbody&gt;<br>                &lt;tr&gt;<br>                    &lt;td&gt;Shweta&lt;/td&gt;<br>                    &lt;td&gt;shweta@gmail.com&lt;/td&gt;<br>                    &lt;td&gt;Mumbai&lt;/td&gt;<br>                &lt;/tr&gt;<br>                &lt;tr&gt;<br>                    &lt;td&gt;Shailesh&lt;/td&gt;<br>                    &lt;td&gt;shailesh@gmail.com&lt;/td&gt;<br>                    &lt;td&gt;Pune&lt;/td&gt;<br>                &lt;/tr&gt;<br>                &lt;tr&gt;<br>                    &lt;td&gt;Vaishali&lt;/td&gt;<br>                    &lt;td&gt;vaishali@gmail.com&lt;/td&gt;<br>                    &lt;td&gt;BMT&lt;/td&gt;<br>                &lt;/tr&gt;<br>            &lt;/tbody&gt;<br>        &lt;/table&gt;<br>    &lt;/div&gt;<br>    &lt;div&gt;<br>        &lt;h3&gt;Bar Chart&lt;/h3&gt;<br>        &lt;div id=&quot;chartContainer1&quot; style=&quot;height: 300px; width: 100%;&quot;&gt;&lt;/div&gt;<br>    &lt;/div&gt;<br>    &lt;div&gt;<br>        &lt;h3&gt;Line Chart&lt;/h3&gt;<br>        &lt;div id=&quot;chartContainer2&quot; style=&quot;height: 300px; width: 100%;&quot;&gt;&lt;/div&gt;<br>    &lt;/div&gt;<br><br>    &lt;script src=&quot;graph.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/head&gt;<br><br>&lt;/html&gt;</pre><h4>➤ graph.js &lt;JS file name&gt;</h4><pre>var chart1 = new CanvasJS.Chart(&quot;chartContainer1&quot;, {<br> title: {<br>   text: &quot;Column Chart&quot;<br>  },<br>  data: [<br>    {<br>      type: &quot;column&quot;,<br>      dataPoints: [<br>        { x: 10, y: 71 },<br>        { x: 20, y: 55 },<br>        { x: 30, y: 50 },<br>        { x: 40, y: 65 },<br>        { x: 50, y: 95 },<br>        { x: 60, y: 68 },<br>        { x: 70, y: 28 },<br>        { x: 80, y: 34 },<br>        { x: 90, y: 14 }<br>      ]<br>    }     <br>  ]<br>});<br><br>chart1.render();<br><br>var chart2 = new CanvasJS.Chart(&quot;chartContainer2&quot;, {<br> title: {<br>   text: &quot;Spline Chart&quot;<br>  },<br>  data: [<br>    {<br>      type: &quot;spline&quot;,<br>      dataPoints: [<br>        { x: 10, y: 71 },<br>        { x: 20, y: 55 },<br>        { x: 30, y: 50 },<br>        { x: 40, y: 65 },<br>        { x: 50, y: 95 },<br>        { x: 60, y: 68 },<br>        { x: 70, y: 28 },<br>        { x: 80, y: 34 },<br>        { x: 90, y: 14 }<br>      ]<br>    }     <br>  ]<br>});<br><br>chart2.render();</pre><p>The above code will create a simple web page that contains a Student table, Column Chart, and Spline Chart like this ⇓</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KLHk78SXaS4lYQZ-Qroz3g.png" /></figure><p>Now I want to download all this stuff into the PDF when clicking on the <strong>“Export as PDF”</strong> button 😱</p><p>For this, we need some libraries 😊</p><ol><li><strong>jsPDF</strong> ➡ JSPDF is an open-source library for <strong>generating PDF documents</strong> using JavaScript. It uses various functions to create various elements of PDF pages.</li><li><strong>html2canvas</strong> ➡ The script allows you to take “screenshots” of webpages or parts of it, directly on the users&#39; browser.</li><li><strong>autotable </strong>➡ This jsPDF plugin adds the ability to generate PDF tables either by parsing HTML tables or by using Javascript data directly.</li></ol><pre>&lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js&quot;&gt;&lt;/script&gt;<br>&lt;script src=&quot;jspdf.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;<br>&lt;script src=&quot;jspdf.plugin.autotable.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre><p>which are already imported in the graph.html file</p><p>Here are jspdf.min.js and jspdf.plugin.autotable.min.js files just use in your project.</p><h4>jspdf.min.js</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37ce05462a571ac8bce399a537fa9cab/href">https://medium.com/media/37ce05462a571ac8bce399a537fa9cab/href</a></iframe><h4>jspdf.plugin.autotable.min.js</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7e9b0a4b25e3afd97c5fbb583482920/href">https://medium.com/media/d7e9b0a4b25e3afd97c5fbb583482920/href</a></iframe><blockquote>Here is the code for exporting the PDF</blockquote><p>You can write in the same file graph.js</p><pre>$(&quot;#exportButton&quot;).click(function(){<br>  var doc = new jsPDF();<br>  var img1, img2;<br>  var pageGap = 10;<br>  doc.setFont(&#39;helvetica&#39;);<br>  doc.setFontType(&#39;bold&#39;);<br>  doc.setFontSize(12);<br>  doc.text(pageGap, pageGap + 25, &#39;Student Table:&#39;);<br><br>  doc.autoTable({ html: &#39;#table&#39;, startY: 50, margin: { right: 10, left: 10 }, pageBreak: &#39;auto&#39; });<br><br>  html2canvas(document.getElementById(&quot;chartContainer1&quot;)).then(function (canvas) {<br><br>    doc.addPage();<br>    img1 = canvas.toDataURL(&quot;image/png&quot;)<br>    doc.addImage(img1, &#39;PNG&#39;, 10, 20, 190, 100);<br>  });<br><br>  html2canvas(document.getElementById(&quot;chartContainer2&quot;)).then(function (canvas) {<br><br>    img2 = canvas.toDataURL(&quot;image/png&quot;)<br>    doc.addImage(img2, &#39;PNG&#39;, 10, 150, 190, 100);<br><br>    doc.save(&quot;CanvasJS Charts.pdf&quot;);<br>  });<br><br>});</pre><p>It will download the PDF successfully 🎉</p><p>PDF <a href="https://coolsymbol.com/copy/Downwards_Black_Arrow_Symbol_%E2%AC%87">⬇</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kBPVusf-9bNIjftkYP90KQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*WogsQJ0ATsdmITcfTzDPlg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83da1fccf843" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gulp in NodeJS Configuration]]></title>
            <link>https://medium.com/@shweta.pawar_93580/gulp-in-nodejs-configuration-421f9da67b82?source=rss-6e7f67220a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/421f9da67b82</guid>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[nodejs-developer]]></category>
            <category><![CDATA[gulp]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Shweta Pawar]]></dc:creator>
            <pubDate>Fri, 29 Jul 2022 08:06:03 GMT</pubDate>
            <atom:updated>2022-07-29T08:06:03.749Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3_-0m1qM3qFfLwPqRqn-Ww.png" /></figure><p>In this article, we will see how to use gulp in nodejs configuration, like local, staging, and prod configuration.</p><h3><strong>What is a gulp?</strong></h3><p>Gulp is a task runner that uses Node. js as a platform. It allows you to do a lot of stuff within your development workflow. It purely uses JavaScript code and helps to run multiple tasks like front-end tasks, large-scale web applications, etc.</p><p><strong>Requirements:</strong></p><ol><li>Install Node. js and npm to your computer.</li><li>Install Gulp and other packages needed for your project.</li><li>Configure your gulpfile.js file to run the tasks you want.</li></ol><p><strong>To Install:</strong></p><pre>npm i gulp</pre><p><strong>Verify your gulp version:</strong></p><pre>gulp --version</pre><p><strong>Configuration:</strong></p><p>Create a file named <em>gulpfile.js</em> in your project root with these contents:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb19e3d306e3b85287ea2b00ea344640/href">https://medium.com/media/fb19e3d306e3b85287ea2b00ea344640/href</a></iframe><p><a href="https://www.npmjs.com/package/gulp-json-editor">gulp-json-editor</a> is a <a href="https://github.com/gulpjs/gulp">gulp</a> plugin to edit JSON objects.</p><p><strong>To run:</strong></p><p>Run the gulp command in your project directory:</p><pre>gulp &lt;task&gt; &lt;othertask&gt; // eg. gulp local or staging or production etc</pre><p>If I run,</p><blockquote><strong>gulp local</strong></blockquote><p>then our config file will override with local credentials.</p><blockquote><strong>gulp staging</strong></blockquote><p>then this will override with staging credentials and so on.</p><p>this is how gulp is used. Instead of doing manually, you can do it using a gulp✌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=421f9da67b82" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[extra_fields in Django]]></title>
            <link>https://blog.nonstopio.com/extra-fields-in-django-9f31e24d7f18?source=rss-6e7f67220a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f31e24d7f18</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[django-framework]]></category>
            <category><![CDATA[information-architecture]]></category>
            <dc:creator><![CDATA[Shweta Pawar]]></dc:creator>
            <pubDate>Mon, 16 May 2022 07:31:13 GMT</pubDate>
            <atom:updated>2022-05-16T07:31:13.419Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*6I05Gq64ivhjcUaztHAk7Q.png" /><figcaption>✨<strong>extra_fields</strong> ✨</figcaption></figure><p><strong><em>extra_fields </em></strong><em>are</em><strong><em> </em></strong><em>used to add extra additional fields in the serializer. Mostly it is used in </em><strong><em>custom serializer.</em></strong></p><p>✨ Let’s try to understand it 👇</p><p>eg. Suppose there are Student, College, and Subjects models.</p><pre>class Student(models.Model):<br>    id = models.AutoField(primary_key=True)<br>    student_name = models.CharField(max_length=120)<br>    age = models.IntegerField()<br><br><br>class College(models.Model):<br>    id = models.AutoField(primary_key=True)<br>    college_name = models.CharField(max_length=120)<br>    student = models.ForeignKey(Student,<br>on_delete=models.CASCADE, null=True)<br><br>class Subjects(models.Model):<br>    id = models.AutoField(primary_key=True)<br>    subject_name = models.CharField(max_length=120)<br>    student = models.ForeignKey(Student, on_delete=models.CASCADE, null=True)</pre><p>If we want to access student and their college and subject information then we can access it by writing a custom serializer. If we want to avoid a custom serializer then use <a href="https://medium.com/nonstopio/related-name-in-django-581128b3507c">related_name</a>.<br>Now we see custom serializer</p><p><strong>Serializer:</strong></p><pre>class StudentSerializer(serializers.ModelSerializer):<br>  <strong>college</strong> = serializers.SerializerMethodField()<br>  <strong>subject</strong> = serializers.SerializerMethodField()<br><br>  def get_college(self, obj):<br>    college_queryset = College.object.filter(student=obj.id)<br>    college_list = []<br>    for collage in college_queryset:<br>      college_list.append(model_to_dict(college))<br>    return college_list<br><br>  def get_subject(self, obj):<br>    subject_queryset = Subject.object.filter(student=obj.id)<br>    subject_list = []<br>    for subject in subject_queryset:<br>      subject_list.append(model_to_dict(subject))<br>    return subject_list<br><br>  class Meta:<br>      model = Student<br>      fields = &#39;__all__&#39;<br>      extra_fields = [&quot;college&quot;, &quot;subject&quot;]</pre><p>📝 <strong>Note:</strong> When we write a custom serializer then must pass the custom serializer name (<strong>college, subject</strong>)in the fields. Otherwise, it gives an error</p><p><strong>Usecase:</strong> If <strong>extra_fields</strong> is not used but we want to mention &quot;college&quot;, &quot;subject&quot; custom serializer name then we need to manually write all Student fields and &quot;college&quot;, &quot;subject&quot;.</p><p>like:</p><pre>class Meta:<br>      model = Student<br>      fields = (&quot;id&quot;, &quot;student_name&quot;, &quot;age&quot;, &quot;college&quot;, &quot;subject&quot;)</pre><p>So simply use <strong><em>extra_fields</em></strong> so that it becomes easy to add extra fields in the serializer instead of writing all fields ✌️</p><p><strong>Usecase Of model_to_dict:</strong></p><ol><li>Import it</li></ol><pre>from django.forms import model_to_dict</pre><p><strong><em>model_to_dict</em></strong> is used to <strong>convert an instance to a dictionary.</strong></p><p>🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f31e24d7f18" width="1" height="1" alt=""><hr><p><a href="https://blog.nonstopio.com/extra-fields-in-django-9f31e24d7f18">💡extra_fields in Django</a> was originally published in <a href="https://blog.nonstopio.com/">nonstopio</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[related_name in Django]]></title>
            <link>https://blog.nonstopio.com/related-name-in-django-581128b3507c?source=rss-6e7f67220a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/581128b3507c</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Shweta Pawar]]></dc:creator>
            <pubDate>Mon, 25 Apr 2022 06:57:11 GMT</pubDate>
            <atom:updated>2022-04-25T06:57:11.751Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aVImN14onAKWKLSfywNCmg.png" /><figcaption>💡 <strong>related_name</strong> 💡</figcaption></figure><h4>related_name is a string that we can specify in the Foreign Key field. The related_name attribute specifies the name of the reverse relation from the User model back to your model. If you don&#39;t specify it Django will provide it.</h4><h3>Example:</h3><p>Suppose there are 2 models 1. Author and 2. Books</p><pre>class Author(models.Model):<br>    author_name = models.CharField(max_length=120)</pre><pre>class Books(models.Model):<br>    book_name = models.CharField(max_length=120)<br>    writen_by = models.ForeignKey(Author, on_delete=models.CASCADE, null=True, related_name=&quot;<strong>authors</strong>&quot;)</pre><ol><li>Here we have the instance of the Books model, we can access the Author information very easily using writen_by. This is called <strong>forward compatibility</strong>. If you want to access a foreign key value then we can access it using the &quot;__&quot; notation.<br><em>eg.</em></li></ol><pre>Books.objects.all().values(&#39;book_name&#39;, &#39;writen_by__author_name&#39;)</pre><p><strong>USECASE of related_name</strong></p><p>✔️ If we want to access Book information from the Author model then what we can do?<br>So There is a special provision in Django to accomplish this called as <strong>backward compatibility</strong>.<br>This can be achieved using <strong><em>related_name</em></strong></p><p><strong>Note:</strong> If you are modifying the model, don’t forget to make the migration.</p><p><em>eg.</em></p><pre>Author.objects.all().values(&#39;author_name&#39;, &#39;authors__book_name&#39;)</pre><p>✔️ If you want to use the same Foreign key multiple times in the same model then also you can use related_name . But related_name should be different for separate fields</p><p><em>eg.</em></p><pre>class Books(models.Model):<br>    book_name = models.CharField(max_length=120)<br>    writen_by = models.ForeignKey(Author, related_name=&quot;<strong>authors</strong>&quot;)<br>    helped_by = models.ForeignKey(Author,<br>related_name=&quot;<strong>helped_author</strong>&quot;)</pre><p>✔️ Also this is useful in the <strong><em>Serializer</em></strong>:</p><p><strong>A.</strong> If I want to access books and their Author Info then the serializer become</p><pre>class AuthorSerializer(serializers.ModelSerializer):<br>    class Meta:<br>        model = Author<br>        fields = &quot;__all__&quot;</pre><pre>class BookSerializer(serializers.ModelSerializer):<br>    writen_by = AuthorSerializer(many=False, read_only=True)<br>    class Meta:<br>        model = Book<br>        fields = &quot;__all__&quot;</pre><p><strong>B.</strong> But what if we want to access Book info from Author? Just mention <em>related_name</em></p><pre>class AuthorSerializer(serializers.ModelSerializer):<br>   authors = BookSerializer(many=True, read_only=True)<br>    class Meta:<br>        model = Author<br>        fields = &quot;__all__&quot;</pre><p>This is how related_name is used .💡</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=581128b3507c" width="1" height="1" alt=""><hr><p><a href="https://blog.nonstopio.com/related-name-in-django-581128b3507c">related_name in Django</a> was originally published in <a href="https://blog.nonstopio.com/">nonstopio</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NPM (Node Package Manager)]]></title>
            <link>https://blog.nonstopio.com/npm-node-package-manager-f5424cb76285?source=rss-6e7f67220a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5424cb76285</guid>
            <dc:creator><![CDATA[Shweta Pawar]]></dc:creator>
            <pubDate>Thu, 21 Apr 2022 04:21:52 GMT</pubDate>
            <atom:updated>2022-04-21T04:21:52.125Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*iahbYjphVbjSQaWHFCTOlg.png" /><figcaption>❤️Node Package Manager❤️</figcaption></figure><h4>NPM is ❤️ of Javascript/Node</h4><p>NPM is a javascript package manager which is basically used to install packages/modules in the project</p><p><em>Install NPM</em>: NPM is installed with Node.js. So just you have to install Node.js</p><h4>To install NPM packages:</h4><blockquote><strong>npm init</strong>: It will create a <em>package.json</em> file.</blockquote><p>Note: This command should run on your root directory i.e your entry point of the project.</p><ul><li><strong>package.json</strong>: The use of this file is that the packages we are installing using NPM will store in it as dependencies. It just contains the package name and its version.</li></ul><p><strong><em>Syntax</em></strong>: npm install &lt;package_name&gt;</p><p>* npm install passport</p><p>package.json</p><pre>eg. {<br>  &quot;dependencies&quot;: {<br>    &quot;passport&quot;: &quot;^0.4.0&quot;,<br>   }<br>}</pre><p>Note: When we install any module 1st time using NPM, it will create a file and folder called <strong><em>package-lock.json(file)</em></strong> and <strong><em>node_modules(folder)</em></strong></p><p><strong>1. package-lock.json</strong> - It contains detailed information about packages/modules which are installed in package.json as dependencies</p><pre>eg. {<br>   &quot;passport&quot;: {<br>      &quot;version&quot;: &quot;0.4.0&quot;,<br>      &quot;resolved&quot;: &quot;<a href="https://registry.npmjs.org/passport/-/passport-0.4.0.tgz">https://registry.npmjs.org/passport/-/passport-0.4.0.tgz</a>&quot;,<br>      &quot;integrity&quot;: &quot;sha1-xQlWkTR71a07XhgCOMORTRbwWBE=&quot;,<br>      &quot;requires&quot;: {<br>        &quot;passport-strategy&quot;: &quot;1.x.x&quot;,<br>        &quot;pause&quot;: &quot;0.0.1&quot;<br>      }<br>    }<br>}</pre><p><strong>2. node_modules</strong>: node_modules folder will contain the files. They will contain the actual code of all installed dependencies. Just you have to <em>require</em> these dependencies in your project and use them.</p><pre>const passport = require(&#39;passport&#39;);</pre><p>Done! ✌ Now only you have to install the required packages which are required for your project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5424cb76285" width="1" height="1" alt=""><hr><p><a href="https://blog.nonstopio.com/npm-node-package-manager-f5424cb76285">💡NPM (Node Package Manager)</a> was originally published in <a href="https://blog.nonstopio.com/">nonstopio</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Authenticate APIs with AWS Cognito]]></title>
            <link>https://blog.nonstopio.com/authenticate-apis-with-aws-cognito-21b6915c1124?source=rss-6e7f67220a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/21b6915c1124</guid>
            <category><![CDATA[web-app-development]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[aws-cognito]]></category>
            <dc:creator><![CDATA[Shweta Pawar]]></dc:creator>
            <pubDate>Mon, 03 May 2021 03:59:36 GMT</pubDate>
            <atom:updated>2021-05-03T03:59:36.302Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LFWWBciAYBqidN2WbRL8Dg.png" /></figure><p><a href="https://aws.amazon.com/cognito/">Aws Cognito</a> lets you easily add user sign-up, sign-in, sign-out, and authentication to your mobile and web apps. Amazon <strong>Cognito</strong> also enables you to authenticate users through an external identity provider and provides temporary security credentials to access your app’s backend resources in <strong>AWS</strong> or any service behind Amazon API Gateway. Amazon <strong>Cognito</strong> provides authentication, authorization, and user management for your web and mobile apps.</p><p>AWS Cognito has 2 main things.</p><ol><li><a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html">User Pool</a></li><li><a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-identity.html">Identity Pool</a></li></ol><p>You can enable your users to authenticate with a user pool. Your app users can sign in either directly through a user pool, or federate through a third-party identity provider (IdP). The user pool manages the overhead of handling the tokens that are returned from social sign-in through Facebook, Google, Amazon, and Apple, and from OpenID Connect (OIDC) and SAML IdPs.</p><p>After successful authentication, your web or mobile app will receive user pool tokens from Amazon <strong>Cognito</strong>. You can <strong>use</strong> those tokens to retrieve <strong>AWS </strong>credentials that allow your app to access other AWS services, or you might choose to use them to control access to your server-side resources, or the Amazon API Gateway.</p><p>Here we are using those access token to authorize our backend APIs</p><p>A. Create a user pool.</p><p>B. Get COGNITO_AWS_REGION, COGNITO_USER_POOL_ID, COGNITO_APP_CLIENT_ID and put them into the settings.py file of our Django project.</p><p>#settings.py</p><pre>COGNITO_AWS_REGION = &#39;ap-south-1&#39;<br>COGNITO_USER_POOL = &#39;ap-south-1_********C&#39; (Pool id)<br>COGNITO_AUDIENCE = &#39;43***********************3&#39; (App client id)</pre><p>C. Install the python-jose library:</p><blockquote>pip install python-jose</blockquote><p>D. Create your customized permission file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc013d8cb7fa609eee5530a6cdc60116/href">https://medium.com/media/fc013d8cb7fa609eee5530a6cdc60116/href</a></iframe><p>E. Use this Authenticate function into our API like:</p><p>#views.py</p><pre>from permissions import Authentication<br>from rest_framework.decorators import permission_classes</pre><pre>class CompanyViewSet(viewsets.ModelViewSet):<br>    permission_classes = (Authentication, )<br>    queryset = Company.objects.all()<br>    serializer_class = CompanySerializer</pre><p>#urls.py</p><p>F. Create URL for it</p><pre>from django.urls import path, include<br>from rest_framework.routers import DefaultRouter<br>from {{app_name}}.views import *<br>router = DefaultRouter()router.register(&#39;company&#39;, CompanyViewSet, basename=&#39;company&#39;)</pre><pre>urlpatterns = [<br> path(&#39;&#39;, include(router.urls)),<br>]</pre><p>G. Test it on postman</p><blockquote><a href="http://localhost:8000/api/v1/docusign_signature/">http://localhost:8000/api/company</a></blockquote><p>with a header containing idToken that is returned by AWS Cognito on the sign-in/sign-up process.</p><h4>Conclusion:</h4><p>We’ve successfully authenticated APIs using AWS Cognito👏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21b6915c1124" width="1" height="1" alt=""><hr><p><a href="https://blog.nonstopio.com/authenticate-apis-with-aws-cognito-21b6915c1124">Authenticate APIs with AWS Cognito</a> was originally published in <a href="https://blog.nonstopio.com/">nonstopio</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docusign integration with Python Django]]></title>
            <link>https://blog.nonstopio.com/docusign-integration-with-python-django-fbd3554f2812?source=rss-6e7f67220a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbd3554f2812</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[esignatures]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[web-app-development]]></category>
            <category><![CDATA[docusign]]></category>
            <dc:creator><![CDATA[Shweta Pawar]]></dc:creator>
            <pubDate>Mon, 03 May 2021 03:51:16 GMT</pubDate>
            <atom:updated>2022-05-25T06:05:19.800Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*vCeqbzSu4-UVLzPxuhkOlw.jpeg" /></figure><p>DocuSign is the fast, reliable way to electronically sign documents and agreements on any device from almost anywhere in the world. I am not talking too much about DocuSign. You can read this more from the official <a href="https://www.docusign.com/">website</a>. In this story, we’re going to cover Docusign integration with Python Django without login</p><p>Let’s start integration:</p><ol><li>You have to create an account on <a href="https://www.docusign.com/">DocuSign</a>.</li><li>Create an <a href="https://developers.docusign.com/docs/esign-rest-api/quickstart/">App</a>.</li><li>Get an integration key, user id, and account id from DocuSign and put them into the settings.py file of our Django project.</li></ol><p>#Settings.py</p><pre># Docusign</pre><pre>CLIENT_AUTH_ID = &#39;54**********************f1&#39; # <strong>Integration Key. (You can get it from Docusign/Settings/Integrations/Apps and Keys/&lt;App name&gt;. App name that you have created in step 2.)</strong></pre><pre>client_user_id = &#39;4*********************9874&#39; # <strong>API Username. (You can get it from Docusign/Settings/Integrations/Apps and Keys/API Username)</strong></pre><pre>account_id = &#39;4c**************************83&#39; # <strong>API Account ID. (You can get it from Docusign/Settings/Integrations/Apps and Keys/API Account ID)</strong></pre><p>4. Libraries needs to install:</p><blockquote>1. pip install docusign-esign</blockquote><blockquote>2. pip install python-jose</blockquote><blockquote>3. pip install cryptography</blockquote><p>5. There are <a href="https://developers.docusign.com/docs/esign-rest-api/how-to/request-signature-email-remote/">multiple ways</a> by using which we can be requesting a signature for the user. Here we are using <a href="https://developers.docusign.com/docs/esign-rest-api/how-to/request-signature-email-remote/">Request a signature by email</a>(remote signing) and <a href="https://developers.docusign.com/docs/esign-rest-api/how-to/request-signature-in-app-embedded/">Request a signature through your app</a>(embedded signing) method for requesting a signature.</p><p>6. The first step is to <strong>Obtain your OAuth token. </strong>There are <a href="https://developers.docusign.com/platform/auth/">3</a> ways by using we can obtain the token. But here we are using “JWT Grant”. For signing without login to the user we are creating a DocuSign JWT token for authentication. For that, create one separate file for creating a DocuSign token named token.py</p><p>a. Create private_key.pem file. In that file past your RSA public and private keys from your DocuSign account. (<strong>Docusign/Settings/Integrations/Apps and Keys/&lt;app_name&gt;/RSA</strong>)</p><p>#{{app}}/tokens.py</p><pre>from {{project_name}} import settings<br>import jwt<br>from jose import jws<br>from cryptography.hazmat.primitives import serialization as crypto_serialization<br>import time</pre><pre>def <strong>docusign_token</strong>():<br>     iat = time.time()<br>     exp = iat+(3600*24)<br>     payload = {<br>         &quot;sub&quot;: settings.client_user_id,<br>         &quot;iss&quot;: settings.CLIENT_AUTH_ID,<br>         &quot;iat&quot;: iat, # session start_time<br>         &quot;exp&quot;: exp, # session end_time<br>         &quot;aud&quot;:&quot;account-d.docusign.com&quot;,<br>         &quot;scope&quot;:&quot;signature&quot;<br>      }<br>     with open(&#39;private_key.pem&#39;, &quot;rb&quot;) as key_file:<br>       private_key = crypto_serialization.load_pem_private_key(key_file.read(), password=None)<br>     key = private_key.private_bytes(crypto_serialization.Encoding.PEM, crypto_serialization.PrivateFormat.PKCS8, crypto_serialization.NoEncryption())</pre><pre>     jwt_token = jws.sign(payload, key, algorithm=&#39;RS256&#39;)<br>     return jwt_token</pre><p>7. Create a docusign.py file into the app folder.</p><p>Here is the main code for getting the JWT token and obtain the access token and then call the appropriate requesting signature method(either by email or embedded)</p><p>#docusign.py</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_wW1Wc6JC3t6bxn702_6SQ.png" /><figcaption>{{app_name}}/docusign.py</figcaption></figure><p><strong>A)</strong> <a href="https://developers.docusign.com/docs/esign-rest-api/how-to/request-signature-email-remote/"><strong>Request a signature by email</strong></a><strong>(remote signing): </strong>This will send an email into your Gmail then you can sign the document</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w9Sz4n5whxFLpoFY50Cppw.png" /><figcaption>{{app_name}}/docusign.py</figcaption></figure><p><strong>B)</strong> <a href="https://developers.docusign.com/docs/esign-rest-api/how-to/request-signature-in-app-embedded/"><strong>Request a signature through your app</strong></a><strong>(embedded signing): </strong>This will return an URL. Just get that URL and put it on the browser. It will open the document onto the browser then you can sign the document. After the document gets signed it will redirect to the <em>sign_completed</em> function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qWvr8fcwaCYbarXhA-4aBA.png" /></figure><p>8. Create URL for it into urls.py</p><pre>from {{app_name}}.docusign import *<br>from django.conf.urls import url<br>from django.urls import path</pre><pre>urlpatterns = [<br>url(https://medium.com/r&#39;^docusign_signature/r&#39;^docusign_signature/$&#39;, docusign_signature, name=&#39;docusign_signature&#39;#39;,%20docusign_signature,%20name=&#39;docusign_signature&#39;),<br>url(https://medium.com/r&#39;^sign_completed/r&#39;^sign_completed/$&#39;, sign_completed, name=&#39;sign_completed&#39;#39;,%20sign_completed,%20name=&#39;sign_completed&#39;),<br>path(&#39;get_envelope_status/&lt;str:envelope_id&gt;&#39;, get_envelope_status, name=&#39;get_envelope_status&#39;),</pre><pre>}</pre><p>9. <a href="https://developers.docusign.com/platform/auth/jwt/jwt-get-token/">Request application consent</a>: Before you can make any API calls using JWT Grant, you must get your user’s consent for your app to impersonate them.</p><pre>https://account.docusign.com/oauth/auth?response_type=code&amp;scope=signature%20impersonation&amp;client_id=&lt;integration_key&gt;&amp;redirect_uri=http://127.0.0.1:8003/</pre><p>Hit this URL on the browser. It will open the DocuSign page to accept it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*RIqxmOWKbzlQkSsjQyiUDw.png" /></figure><p>10. For testing, open postman then hit</p><blockquote><a href="http://localhost:8000/api/v1/docusign_signature/">http://localhost:8000/api/v1/docusign_signature/</a></blockquote><p>with the request body</p><pre>{<br> &quot;email&quot;:&quot;s<a href="/service/mailto:shweta.pawar@nonstopio.com">.p@nonstopio.com</a>&quot;,<br> &quot;full_name&quot;: &quot;SP&quot;,<br> &quot;type&quot;: &quot;either embedded/email&quot;,<br>}</pre><p>11. To test the envelope status</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*7cnPaUXkbKjV25965wMP-w.png" /><figcaption>{{app_name}}/docusign.py</figcaption></figure><h3><strong>Conclusion</strong>:</h3><p>The signer can sign the document without Login into the DocuSign account. ✌️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbd3554f2812" width="1" height="1" alt=""><hr><p><a href="https://blog.nonstopio.com/docusign-integration-with-python-django-fbd3554f2812">Docusign integration with Python Django</a> was originally published in <a href="https://blog.nonstopio.com/">nonstopio</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Restful APIs and Model creation in Ruby on Rails]]></title>
            <link>https://blog.nonstopio.com/restful-apis-and-model-creation-in-ruby-on-rails-8ce59235f0b5?source=rss-6e7f67220a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ce59235f0b5</guid>
            <category><![CDATA[web-app-development]]></category>
            <category><![CDATA[orm]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Shweta Pawar]]></dc:creator>
            <pubDate>Sun, 04 Oct 2020 17:08:06 GMT</pubDate>
            <atom:updated>2020-10-04T17:08:06.753Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*zOFl4Fm_ENxjQaB3CjEAXg.jpeg" /></figure><p><a href="https://api.rubyonrails.org/files/activerecord/README_rdoc.html">Active Record</a><strong> </strong>plays the most important role in ROR. Active Record is the ORM (Object-relational mapping) of rails. Using the Active Record we can perform CRUD operation in ROR and manages all database related operations. It is a model aspect of rails and it is representative of data. Is allows you to present data from databases rows as objects and used in business logic</p><h3>1. Create models:</h3><p>We can create models in ROR using rails like 👇</p><pre>rails generate model model_name field_name:type, field_name:type...</pre><p>We will create some sample models for your understanding</p><p>Company model:</p><pre>1. rails generate model Company name:string email:string address:string</pre><p>Adding foreign key in the Employee model:</p><pre>rails generate model Employee name:string emp_id:string company:references</pre><p>here I have added the company primary key as an FK.</p><p>Here 👇 is a sample demo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6haWFsmMGm6r8BiH5fAHaA.png" /></figure><p>It creates a migration file in the db/migrate folder. After that, we can migrate all created model into our selected database(MySQL, Postgres, etc)</p><p>Using command 👇</p><pre>rake db:migrate</pre><p>It migrates all the models into our database. Yeah! here we have created models. Now we will perform CRUD operations.</p><h3>2. CRUD</h3><p>Here we will create api/v1 folder under the app/controller folder and will start writing our APIs finally 💥</p><p>In the app/controller/api/v1 folder, I have created a file named company_controller.rb 👇</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd60529b1a232a19b10f869408ed94cc/href">https://medium.com/media/bd60529b1a232a19b10f869408ed94cc/href</a></iframe><p>Also In the same folder, I have created a file named employee_controller.rb 👇</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad8cdb82d64171a3dbec55a30d9963a6/href">https://medium.com/media/ad8cdb82d64171a3dbec55a30d9963a6/href</a></iframe><p>Here we have created all CRUD operations related to the company model and the employee model. also did pagination in the company index function with proper error handling and logging.</p><p><strong>A.</strong> In ROR we perform error handling using 👇</p><pre>begin<br>   //some code<br>rescue =&gt; e<br>end</pre><p><strong>B.</strong> Rails provide logging functionality with its own, you just use</p><pre>Rails.logger.{type}  type:(info, warn, debug etc,)</pre><p><strong>C.</strong> You can also create fake data. For this purpose, you add the <strong>gem ‘faker’ </strong>in Gemfile then run<strong> bundle install.</strong></p><p>For creating fake data you can write code in db/seeds.rb file like 👇</p><pre>5.times do</pre><pre>Company.create({</pre><pre>name: Faker::Name.name,</pre><pre>email: Faker::Internet.email,</pre><pre>address: Faker::Book.title</pre><pre>})</pre><pre>end</pre><pre>5.times do</pre><pre>Employee.create({</pre><pre>name: Faker::Name.name,</pre><pre>emp_id: Faker::Number.number(digits: 10),</pre><pre>company: 1</pre><pre>})</pre><pre>end</pre><p>migrate fake data into the database</p><pre>rails db:seed =&gt; used for migrate fake data</pre><h4>Creates Routes:</h4><p>You can create routes in config/routes.rb file</p><pre>Rails.application.routes.draw do</pre><pre>mount Rswag::Ui::Engine =&gt; &#39;/api-docs&#39;</pre><pre>mount Rswag::Api::Engine =&gt; &#39;/api-docs&#39;</pre><pre># For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html</pre><pre>namespace &#39;api&#39; do // folder name that we have created in controller folder for CRUD</pre><pre>namespace &#39;v1&#39; do</pre><pre>resources :company </pre><pre>post &#39;company/search&#39; // custome route</pre><pre>post &#39;company/search_query&#39;</pre><pre>resources :employee</pre><pre>end</pre><pre>end</pre><pre>end</pre><h3>Testing:</h3><p>ROR provides routes. We can check all routes of ROR using:</p><pre>rails routes =&gt; show all routes</pre><p>For <a href="https://medium.com/nonstopio/create-restful-apis-using-node-js-and-mysql-9e4f06058aad">testing</a>, you can refer to my previous blog.</p><h3>Conclusion:</h3><p>Yeah! 👏 we finally have done all CRUDs and Models 💥</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ce59235f0b5" width="1" height="1" alt=""><hr><p><a href="https://blog.nonstopio.com/restful-apis-and-model-creation-in-ruby-on-rails-8ce59235f0b5">Restful APIs and Model creation in Ruby on Rails</a> was originally published in <a href="https://blog.nonstopio.com/">nonstopio</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step up of Ruby On Rails]]></title>
            <link>https://blog.nonstopio.com/step-up-of-ruby-on-rails-f4cecec64400?source=rss-6e7f67220a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4cecec64400</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[web-app-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Shweta Pawar]]></dc:creator>
            <pubDate>Sun, 04 Oct 2020 17:08:02 GMT</pubDate>
            <atom:updated>2020-10-04T17:08:02.367Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*golXFVCPKCg9kddbSEQCZA.jpeg" /></figure><h4><a href="https://rubyonrails.org/">Ruby on Rails</a> is the most popular open-source web application framework. It’s built with the Ruby programming language. You can use the Rails framework to build your applications, from simple to complex. ROR follows <a href="https://api.rubyonrails.org/">MVC</a> architecture.</h4><h3>Installing Ruby</h3><p>Installation using <strong>rbenv</strong>:</p><p>Installingrbenv is a simple two-step process. First, you install rbenv, and then ruby-build:</p><pre>cd<br>git clone https://github.com/rbenv/rbenv.git ~/.rbenv<br>echo &#39;export PATH=&quot;$HOME/.rbenv/bin:$PATH&quot;&#39; &gt;&gt; ~/.bashrc<br>echo &#39;eval &quot;$(rbenv init -)&quot;&#39; &gt;&gt; ~/.bashrc<br>exec $SHELL<br><br>git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build<br>echo &#39;export PATH=&quot;$HOME/.rbenv/plugins/ruby-build/bin:$PATH&quot;&#39; &gt;&gt; ~/.bashrc<br>exec $SHELL<br><br>rbenv install 2.7.1<br>rbenv global 2.7.1<br>ruby -v</pre><h3>Installing Rails</h3><p>We can install any version, but here I have installed v6</p><pre>gem install rails -v 6.0.2.2</pre><p>If you’re using rbenv, you’ll need to run the following command to make the rails executable available:</p><pre>rbenv rehash</pre><p>Now check the rails version:</p><pre>rails -v</pre><h3>Setting Up A Database</h3><p>Rails used sqlite3 as the default database. But you can easily use MySQL or PostgreSQL.</p><p>Here I have used PostgreSQL</p><p>If PostgreSQL is not installed 👇 this command will install the latest version of Postgres.</p><pre>sudo apt install postgresql-11 libpq-dev</pre><p>Create a user of Postgres:</p><pre>sudo -u postgres createuser user_name -s<br><br># If you would like to set a password for the user, you can do the following<br>sudo -u postgres psql<br>postgres=# \password user_name</pre><h3>Final Steps</h3><p>Let’s create your first Rails application:</p><pre>#### If you want to use SQLite (default)<br>rails new myapp<br><br>#### If you want to use MySQL<br>rails new myapp -d mysql<br><br>#### If you want to use Postgres<br># Note that this will expect a postgres user with the same username<br># as your app, you may need to edit config/database.yml to match the<br># user you created earlier<br>rails new myapp -d postgresql<br><br># Move into the application directory<br>cd myapp<br><br># If you setup MySQL or Postgres with a username/password, modify the<br># config/database.yml file to contain the username/password that you specified<br><br># Create the database<br>rake db:create<br><br>rails server</pre><p>You can now visit <a href="http://localhost:3000/">http://localhost:3000</a> to view your new website!</p><p>If you received an error that said Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: NO) then you need to update your config/database.yml file to match the database username and password.</p><p>ROR creates its own folder structure. You can see all information about its structure 👉 <a href="https://guides.rubyonrails.org/v5.2/getting_started.html">here</a></p><p>If you want to add extra packages using gem then you can directly write in Gemfile and after that run:</p><pre>bundle install</pre><p>It will install all packages you have added in Gemfile</p><h3>Conclusion:</h3><p>ROR installation is done 💥 👏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4cecec64400" width="1" height="1" alt=""><hr><p><a href="https://blog.nonstopio.com/step-up-of-ruby-on-rails-f4cecec64400">Step up of Ruby On Rails</a> was originally published in <a href="https://blog.nonstopio.com/">nonstopio</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nodejs with Swagger]]></title>
            <link>https://blog.nonstopio.com/nodejs-with-swagger-2fd26ea02436?source=rss-6e7f67220a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fd26ea02436</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Shweta Pawar]]></dc:creator>
            <pubDate>Tue, 25 Aug 2020 07:30:43 GMT</pubDate>
            <atom:updated>2020-08-25T07:30:43.297Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*jwqn-eZdU7AsQCxrdGvyrQ.png" /></figure><h3>What is Swagger</h3><p><a href="https://swagger.io/">Swagger</a> is the largest framework for designing APIs using a common language with including documentation, design, testing, and deployment. Swagger easily comprehensible for both developers and non-developers. Thus, software developers, product and project managers, business analysts, etc can access API design. Also, as Swagger is easily adjustable, it can be successfully used for API testing and bug fixing.</p><p>There are 2 packages are used for integrating swagger with APIs in nodejs:</p><ul><li><a href="https://www.npmjs.com/package/swagger-jsdoc"><strong>swagger-jsdoc</strong></a></li><li><a href="https://www.npmjs.com/package/swagger-ui-express"><strong>swagger-ui-express</strong></a></li></ul><h3>Usage</h3><p>Install using npm:</p><pre>npm i swagger-jsdoc swagger-ui-express</pre><p>after that define routes in the main file called server.js and integrate swagger code for per API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFVTI4I4Ife05RzXQtBg5w.png" /></figure><p>To check the swagger API documentation</p><ol><li>Run the server:</li></ol><blockquote>npm run start</blockquote><p>2. Open chrome and past server IP address like:</p><blockquote><a href="http://localhost:3000/api-docs/">http://localhost:3000/api-docs/</a></blockquote><p>It looks like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vVNZTxgbvlLQEQRne7OhJw.png" /></figure><p>Yeah! We successfully integrated Swagger 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fd26ea02436" width="1" height="1" alt=""><hr><p><a href="https://blog.nonstopio.com/nodejs-with-swagger-2fd26ea02436">Nodejs with Swagger</a> was originally published in <a href="https://blog.nonstopio.com/">nonstopio</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>