<?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:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Izabel Vasilyovska - SashiDo.io | API Development, Deployment and Scaling made simple.]]></title><description><![CDATA[SashiDo.io is a serverless API development platform with scalable json rest and graphql apis, headless cms, built with nodejs, mongodb, parse server, kubernetes and docker.]]></description><link>https://blog.sashido.io/</link><image><url>https://blog.sashido.io/favicon.png</url><title>Izabel Vasilyovska - SashiDo.io | API Development, Deployment and Scaling made simple.</title><link>https://blog.sashido.io/</link></image><generator>Ghost 1.20</generator><lastBuildDate>Tue, 26 May 2026 05:00:47 GMT</lastBuildDate><atom:link href="https://blog.sashido.io/author/izabel/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Migrate to Firebase Cloud Messaging API (V1)]]></title><description><![CDATA[Google deprecated the old Firebase Cloud Messaging (FCM) Legacy API on June 20, 2024. Switch to the new FCM HTTP (v1) API for enhanced security, messaging options, and performance. Check out SashiDo's step-by-step tutorial that simplifies your migration process.]]></description><link>https://blog.sashido.io/migrate-to-firebase-cloud-messaging-api-v1/</link><guid isPermaLink="false">666830ee7e04c40027134cbe</guid><category><![CDATA[android-push-notifications]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[android]]></category><category><![CDATA[Push Notifications]]></category><dc:creator><![CDATA[Izabel Vasilyovska]]></dc:creator><pubDate>Sun, 16 Jun 2024 11:31:07 GMT</pubDate><media:content url="https://media-blog.sashido.io/content/images/2024/06/firebase-cover.png" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://media-blog.sashido.io/content/images/2024/06/firebase-cover.png" alt="Migrate to Firebase Cloud Messaging API (V1)"><p>As of June 20, 2024, Google deprecated the old Firebase Cloud Messaging (FCM) Legacy API, so everyone using this service has to switch to the new and improved FCM HTTP (v1) API. This update brings better security, more messaging options, and smoother performance, helping you keep the lines of communication open with your users.</p>
<p>At SashiDo, we want to make this transition as smooth as possible for our clients, so we've prepared a tutorial on describing the introduced changes and on the exact steps to migrating to the new API. Check out the guide in the following lines!</p>
<h1 id="updateyourfirebasedependencies">Update Your Firebase Dependencies</h1>
<p>Now that you know what’s changing and how the SashiDo Push Notifications Service works, we can continue with the actual settings. The first thing to do is ensure you’re using the latest versions of Firebase libraries in your app and familiarise yourself with the <a href="https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Notification">FCM REST API V1 Reference</a> and the <a href="https://firebase.google.com/docs/cloud-messaging/migrate-v1">FCM Migration Guidelines</a>.</p>
<h1 id="fcmapiv1enabled">FCM API (V1) Enabled</h1>
<p>For both old and new projects, the FCM V1 API is already enabled by default. However, if you’ve got an older project you might have the Legacy API enabled as well until it’s fully deprecated*.</p>
<p>To check that head over to the <a href="https://console.firebase.google.com/">Firebase Console</a> and open your project. From there click on the gear icon next to Project Overview that’s located on top of the left-hand menu and select Project settings.</p>
<p><img src="https://media-blog.sashido.io/content/images/2024/06/Screenshot-2024-06-11-at-14.44.43-1.png" alt="Migrate to Firebase Cloud Messaging API (V1)"></p>
<p>Once on the Project settings page, select the Cloud Messaging tab. If the V1 API is disabled, click on the kebab menu next to it and choose Manage API in Google Cloud Console.</p>
<p><img src="https://media-blog.sashido.io/content/images/2024/06/Image-11.06.24-at-14.59.jpeg" alt="Migrate to Firebase Cloud Messaging API (V1)"></p>
<blockquote>
<p>*<strong>Pro tip:</strong> Referring to Firebase’s FAQ about the FCM features deprecated in June 2023, they will start generating a small number of errors on the current API around July 22th, 2024 and gradually ramp-down. Customers can apply for an extension here if they can't finish the migration by then.</p>
</blockquote>
<h1 id="generateaprivatekey">Generate a Private Key</h1>
<p>Head back to <strong>Project settings</strong> and click on the <strong>Service Accounts Tab</strong>. From there click on <strong>Generate new private key</strong>.</p>
<p><img src="https://media-blog.sashido.io/content/images/2024/06/Image-11.06.24-at-14.52.jpeg" alt="Migrate to Firebase Cloud Messaging API (V1)"></p>
<p>This will download a JSON file. Store it someplace safe.</p>
<h1 id="switchfromlegacytov1insashido">Switch from Legacy to V1 in SashiDo</h1>
<p>Go to your <a href="https://dashboard.sashido.io/">SashiDo app’s Dashboard</a>. From there, on the left-hand menu, click on <strong>App Settings &gt; Push</strong>. From there, upload the JSON file to the <strong>Android Push Credentials</strong> section and click on <strong>Save Changes</strong> on the bottom right of the screen.<br>
<img src="https://media-blog.sashido.io/content/images/2024/06/Screenshot-2024-06-16-at-14.25.44.png" alt="Migrate to Firebase Cloud Messaging API (V1)"></p>
<h1 id="testpushnotificationfunctionality">Test Push Notification Functionality</h1>
<p>And do not forget! After making the necessary changes, test your notifications to ensure they are being sent and received correctly.</p>
<p>We always recommend following the best practices and testing on a dev environment first before migrating in production. You can send push notifications in several ways. The most straightforward way to do that is through the Dashboard. On the left-hand menu click on Push and select Send New Push. From there, select your audience and write a quick message under “Write your message”. Once you’re ready, click on Send Push. After you’ve sent your push notification, you can check the status from the Activity tab.</p>
<p>If you haven’t set up push notifications for your Android app yet, check out our article on <a href="https://blog.sashido.io/android-push-notifications-with-sashido-step-by-step/">How to Integrate Push Notifications in Android Step by Step</a>.</p>
<h1 id="conclusion">Conclusion</h1>
<p>Although SashiDo’s Push Notification Service automatically handles many of the necessary adjustments, we strongly advise our customers to structure their payloads to align with FCM requirements and fields. Ensuring your payloads are properly formatted will lead to more reliable and efficient push notification delivery.</p>
<p>For more detailed information, refer to the <a href="https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#Notification">FCM REST API V1 Reference</a> and the <a href="https://firebase.google.com/docs/cloud-messaging/migrate-v1">FCM Migration Guidelines</a>. If you need any assistance, feel free to reach out at <a href="mailto:support@sashido.io">support@sashido.io</a>.</p>
<p>Happy Coding!</p>
</div>]]></content:encoded></item><item><title><![CDATA[Accelerate App Development with AI: A Guide to Seamlessly Integrate SashiDo and Locofy]]></title><description><![CDATA[In this tutorial, we'll show you how you can launch a functional notes app in 30 minutes by leveraging the power of AI. From design to production with the help of SashiDo and Locofy.]]></description><link>https://blog.sashido.io/accelerating-app-development-with-ai/</link><guid isPermaLink="false">652dfd7e29cfdf0022b3dab1</guid><category><![CDATA[AI]]></category><category><![CDATA[Beginner Project]]></category><category><![CDATA[Parse Server]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Locofy]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Izabel Vasilyovska]]></dc:creator><pubDate>Thu, 23 Nov 2023 13:41:10 GMT</pubDate><media:content url="https://media-blog.sashido.io/content/images/2023/10/cover-3--1-.png" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><h1 id="introduction">Introduction</h1>
<img src="https://media-blog.sashido.io/content/images/2023/10/cover-3--1-.png" alt="Accelerate App Development with AI: A Guide to Seamlessly Integrate SashiDo and Locofy"><p>In today's fast-paced world, integrating AI into your work can significantly streamline your project's development process and make your life easier. <a href="https://www.sashido.io/en">SashiDo</a>, a fully managed mobile backend-as-a-service (MBaaS), and <a href="https://www.locofy.ai/">Locofy</a>, an AI-powered platform that converts your designs into production-ready code, together provide a powerful combination that seamlessly integrates backend and frontend functionalities.</p>
<p>In this tutorial, we'll show you how you can launch a functional notes app in 30 minutes without compromising the quality of your work. From design to production with the help of SashiDo and Locofy.</p>
<h1 id="setupyoursashidoappanddevelopmentenvironment">Set up your SashiDo app and development environment</h1>
<p>If you’re new to SashiDo, make sure to first check our <a href="https://blog.sashido.io/sashidos-getting-started-guide/">Getting Started Guide</a> to seamlessly initiate your SashiDo app and get to know the platform.</p>
<p>To get started, you’ll need to <a href="https://dashboard.sashido.io/create">create a SashiDo app</a>. Once your app is ready, head over to its <strong>Dashboard</strong> &gt; <strong>Core</strong> &gt; <strong>Cloud Code</strong> and click on <strong>Start your Cloud Code</strong>.</p>
<p><strong>Note</strong>: If you haven’t connected your SashiDo and GitHub accounts, click on the button <strong>Connect to GitHub</strong>. Once you’ve connected the accounts you’ll see the <strong>Start your Cloud Code</strong> button.</p>
<p>Afterwards, head over to your app’s private GitHub repo and fork the project. You’ll need the forked repo once you’re ready to export the code from Locofy.</p>
<p><iframe width="854" height="480" src="https://www.youtube.com/embed/I1hkJNY1xvo?si=LSdpjn1u0vQ9sJQG" title="How to Fork a GitHub Repo" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe></p><p>
</p><p>Then, simply follow the steps from the repo’s README to set up your local development environment. You can also follow our Blog post on <a href="https://blog.sashido.io/creating-a-development-environment/">creating a development environment from scratch</a> for more details.</p>
<h1 id="setupyourdatabaseinsashido">Set up your database in SashiDo</h1>
<p>The app is very simple so you just need to create a new class where you’re going to store the notes. You can do that from your app’s <strong>Dashboard</strong> &gt; <strong>Core</strong> &gt; <strong>Browser</strong> &gt; <strong>Create a Class</strong>.</p>
<h1 id="getstartedwithlocofy">Get started with Locofy</h1>
<p><a href="https://www.locofy.ai/">Locofy</a> is a Figma and AdobeXD plugin that accelerates Frontend Development with the help of AI by transforming designs into robust frontend code for web applications.</p>
<p>To get started with Locofy you can first <a href="https://www.locofy.ai/signup">create an account</a>. After that, simply <a href="https://www.locofy.ai/dashboard/my-projects">create a new project</a>  and pick the framework you wish to work with. You can also check out Locofy’s <a href="https://www.locofy.ai/docs/">documentation</a> beforehand if you want to get familiar with the tool.</p>
<h1 id="makeyourdesignresponsive">Make your design responsive</h1>
<p>You can find the <a href="https://www.figma.com/">Figma</a> design we’re using <a href="https://www.figma.com/file/Gy7Oq8HsvznMYjbCYhFjOU/App?type=design&amp;node-id=104%3A484&amp;mode=design&amp;t=72CjUSeeC9PwIdXx-1">here</a>. However, feel free to use a design of your own if you’d like.</p>
<p>Essentially, if your design is responsive in Figma, then it will also be responsive in Locofy. With that in mind, let’s get into it.</p>
<p>To make the design responsive in Figma, you can use <a href="https://help.figma.com/hc/en-us/articles/360040451373-Explore-auto-layout-properties">Auto Layout</a>. This is a property you can add to frames and components. It lets you create designs that grow to fill or shrink to fit, and reflow as their contents change.</p>
<p>You can add auto layout to each frame/component as well as change the horizontal resizing to <strong>Fill</strong> and the vertical resizing to <strong>Hug</strong>.<br>
Once you’re done with the previous step, you can open the Locofy plugin from Figma to continue preparing the design for production. To open the plugin, click on <strong>Resources</strong> &gt; <strong>Plugins</strong> and type in Locofy.</p>
<p><iframe width="854" height="480" src="https://www.youtube.com/embed/SgYFv4__bt0?si=QB5b5WM3ZHaoqmtc" title="Locofy Plugin" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe></p><p>
</p><p>If this is your first time using the plugin, you’ll need to link your Figma and Locofy accounts. Just follow the instructions that appear on the plugin screen to link your accounts.</p>
<p>Once you’re done with that and have the plugin opened, select the outermost frame and click on <strong>Step 1: Optimise design</strong>. From there, under <strong>Next, let’s apply Auto-Layout</strong> click on the green button next to Actions and select <strong>Fill container</strong>.</p>
<p>Moving forward, let’s handle the different screen sizes. Simply click on <strong>Fix</strong> next to each frame and if necessary change how the frames should move on different screen sizes.</p>
<p>The next step is to tag your layers. <strong>Click on Step 2: Tag your layers</strong> and click on <strong>View all layers</strong>. Below you can find how we’ve tagged our layers.</p>
<p><img src="https://media-blog.sashido.io/content/images/2023/10/tag-layers-my-structure-copy.png" alt="Accelerate App Development with AI: A Guide to Seamlessly Integrate SashiDo and Locofy"></p>
<p>Once the above-mentioned layers have been tagged you can continue manually tagging your layers or you can go back and click on Auto-Tag so Locofy can give you suggestions.<br>
<img src="https://media-blog.sashido.io/content/images/2023/10/tag-layers.png" alt="Accelerate App Development with AI: A Guide to Seamlessly Integrate SashiDo and Locofy"></p>
<p>After you tagged your layers, you can click on <strong>Preview</strong> and see what the design looks like. You may notice a border around the input area. You can remove the border by clicking on <strong>Step 3: Edit styling &amp; layout</strong>. From there scroll to the bottom and under <strong>Advanced CSS Properties</strong> you can add <code>outline: none</code> to remove it. You can also change the colour of the text you’re inputting if you’d like.</p>
<p><img src="https://media-blog.sashido.io/content/images/2023/10/advanced-css-properties-copy.png" alt="Accelerate App Development with AI: A Guide to Seamlessly Integrate SashiDo and Locofy"></p>
<h1 id="exportthelocofycodetoyourprivategithubrepo">Export the Locofy code to your private GitHub repo</h1>
<p>Now it’s time to sync all of these changes to the Locofy Builder. Simply go back to the start page of the plugin and click on <strong>Sync to Builder</strong>. After that click on <strong>Selected Frames</strong> (you should sync the Content frame) and <strong>Start Sync</strong>.</p>
<p><iframe width="854" height="480" src="https://www.youtube.com/embed/T-r7xWIbJxk?si=4_gLjPtduGiee6h3" title="Sync Design to Locofy Builder" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe></p><p>
</p><p>Once you’re in the Builder you can view your prototype to see if you’re satisfied with the results. After that, you can sync the project with the forked GitHub repo of your SashiDo app. Simply click on <strong>Sync /Export /Deploy</strong> and from there select <strong>Sync Project</strong>.</p>
<p>If you haven’t linked your Locofy and GitHub accounts, you’ll be prompted to do so. Simply follow the instructions that appear onscreen.</p>
<p>Once your accounts are linked select the forked repo of your SashiDo app. A new window will appear. On the left will be the current contents of your repo and on the right will be the Locofy files. Our recommendation is to match the file structure of your GitHub repo. On this window, you can move around files, create new folders and select which files you’d like to push to GitHub.</p>
<p><iframe width="854" height="480" src="https://www.youtube.com/embed/NRbyBaI2mOo?si=jVFvR53K8EQ2mGvj" title="Sync Locofy to GitHub" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe></p><p>
</p><p>Once you’re done with the file structure, you can deselect the <strong>.gitignore</strong> and <strong>package.json</strong> files. You’ll also be prompted to first resolve conflicts. After that, simply click on <strong>Push to GitHub</strong> and in a matter of seconds the code generated by Locofy will be in your GitHub repo.</p>
<h1 id="checkyourfiles">Check your files</h1>
<p>Head over to VisualStudio Code and open a terminal. If you’ve already set up your development environment, type <code>git pull</code> to get the newest addition from your app’s repo.<br>
As a first step check if any files are missing. The following files from Locofy should have been imported:</p>
<ul>
<li>global.css</li>
<li>index.css</li>
<li>index.html</li>
</ul>
<p>Afterwards, open <code>index.html</code> and check if the paths of your CSS files are correct. If they aren’t, now’s the time to fix them.</p>
<h1 id="connectyourlocofycodewithyoursashidoapp">Connect your Locofy code with your SashiDo app</h1>
<p>Now it’s time to write some code so the app actually works. Firstly, let’s add some id’s to three classes. Head over to <code>index.html</code> and add the following id’s to these classes:</p>
<p><code>class=&quot;share-something-cool&quot; id=&quot;noteInput&quot;</code><br>
<code>class=&quot;actions1&quot; id=&quot;saveButton&quot;&gt;</code><br>
<code>class=&quot;notes1&quot; id=&quot;notesSection&quot;&gt;</code></p>
<p>Then, create a new JS file <code>feed.js</code> and <a href="https://docs.parseplatform.org/js/guide/#getting-started">initialize Parse</a>. After that, add the following code to save new entries to your SashiDo app.</p>
<p>If you haven’t done so already, this code will create a new class called “Note” with a field called “content” where the entries will be saved.</p>
<pre><code class="language-js">const saveButton = document.getElementById(&quot;saveButton&quot;);
saveButton.addEventListener(&quot;click&quot;, () =&gt; {
  const Note = Parse.Object.extend(&quot;Note&quot;);
  const note = new Note();


  const noteInput = document.getElementById(&quot;noteInput&quot;).value;
  note.set(&quot;content&quot;, noteInput);


  note.save().then(
    () =&gt; {
      alert(&quot;Data saved to your app.&quot;);
    },
    (error) =&gt; {
      console.error(&quot;Error saving to your app: &quot;, error);
    }
  );
});
</code></pre>
<p>Afterwards, you’ll add a query that fetches the entries from your database and sorts them by date and time (the newest entries will be on top of the page)</p>
<pre><code class="language-js">const Notes = Parse.Object.extend(&quot;Note&quot;);
const query = new Parse.Query(Notes);


query
  .find()
  .then((results) =&gt; {
    const notesSection = document.getElementById(&quot;notesSection&quot;);


    results.reverse().forEach((note) =&gt; {
      const noteContent = note.get(&quot;content&quot;);
      const createdAt = note.get(&quot;createdAt&quot;);


      const noteSection = document.createElement(&quot;div&quot;);
      noteSection.classList.add(&quot;notes2&quot;);


      noteSection.innerHTML = `
                &lt;div class=&quot;infos-actions1&quot;&gt;
                    &lt;div class=&quot;info&quot;&gt;
                        &lt;div class=&quot;heading-infos&quot;&gt;
                            &lt;div class=&quot;username&quot;&gt;John Doe&lt;/div&gt;
                            &lt;div class=&quot;right-infos&quot;&gt;
                                &lt;div class=&quot;min&quot;&gt;${createdAt.toLocaleString()}&lt;/div&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div class=&quot;lorem-ipsum-dolor&quot;&gt;${noteContent}&lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                `;
      notesSection.appendChild(noteSection);
    });
  })
  .catch((error) =&gt; {
    console.error(&quot;Error fetching from Parse Server: &quot;, error);
  });
</code></pre>
<p>As a last step, you’ll need to add a new line to your CSS file. Head over to index.css and ensure this is what your notes1 class looks like:</p>
<pre><code class="language-css">.notes1 {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border-color);
  align-items: flex-start;
  justify-content: flex-start;
  padding: var(--padding-base) 0;
  text-align: left;
  font-size: var(--font-size-sm);
  color: var(--color-black);
  font-family: var(--font-inter);
}
</code></pre>
<p>After that simply open your page and your app should look something like this:<br>
<img src="https://media-blog.sashido.io/content/images/2023/10/Screenshot-2023-10-17-064137.png" alt="Accelerate App Development with AI: A Guide to Seamlessly Integrate SashiDo and Locofy"></p>
<h1 id="conclusion">Conclusion</h1>
<p>In conclusion, the integration of AI tools with the functionalities of <a href="https://www.sashido.io/en">SashiDo</a> presents a forward-looking solution for developers to streamline and expedite their project management and deployment processes. By implementing the outlined steps, you can effortlessly establish a dynamic development environment and seamlessly synchronize your AI-generated code between <a href="https://www.locofy.ai/">Locofy</a> and your SashiDo application.</p>
<p>Integrating AI into your daily work life not only ensures an efficient and user-friendly development experience but also empowers you to dedicate more energy to your creative concepts and less to the intricacies of technical implementation.</p>
</div>]]></content:encoded></item><item><title><![CDATA[Implementing Two-factor Authentication like a Pro]]></title><description><![CDATA[See how you can easily make your users' accounts more secure by implementing Two-Factor authentication into your SashiDo app.]]></description><link>https://blog.sashido.io/implementing-two-factor-authentication-like-a-pro/</link><guid isPermaLink="false">64d3504b29cfdf0022b3da99</guid><category><![CDATA[Tutorial]]></category><category><![CDATA[2FA]]></category><category><![CDATA[Beginner Project]]></category><dc:creator><![CDATA[Izabel Vasilyovska]]></dc:creator><pubDate>Mon, 14 Aug 2023 07:41:19 GMT</pubDate><media:content url="https://media-blog.sashido.io/content/images/2023/08/cover-2fa.jpg" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://media-blog.sashido.io/content/images/2023/08/cover-2fa.jpg" alt="Implementing Two-factor Authentication like a Pro"><p>In the following tutorial, we are going to cover what is Two-factor authentication, how the 2FA API works and how you can integrate it into your SashiDo app. We are certain that by the end of the article, you will be thrilled to take your application’s security to another level!</p>
<h1 id="introductiontotwofactorauthentication">Introduction to Two-factor authentication</h1>
<p>2FA is a security mechanism that adds an extra layer of protection to your online accounts, making them more secure than just relying on a password alone. It requires users to provide two different authentication factors before they can access their accounts, one of which is their password.</p>
<p>Nowadays, passwords are not a sufficient measure that guarantees 100% protection against malicious intents. A database breach, keylogger or a simple phishing email is sometimes enough to break a password and gain access to an account. Therefore it’s important to have this extra layer of protection.</p>
<h1 id="howtwofactorauthenticationworks">How Two-factor authentication works</h1>
<p>Whenever a user is logging into an account, usually they are required to use their username/email address and their password. As we have already deduced, it is not that hard to become a victim of a hacker’s attack, so it is crucial to have your credentials well protected.</p>
<p>This is where 2FA comes into play. In the unfortunate event when someone manages to access your users’ accounts, upon successful login, they will be prompted for a second verification - a one-time unique code will be generated and sent as an SMS to your user's mobile phone number. The code is only valid for a limited time window and if not added, it simply expires. Without the secret set of symbols, the user can’t complete the verification and no access will be granted which increases the safety of the account.</p>
<h1 id="implementtwofactorauthenticationintoyourappusingcloudcode">Implement Two-factor authentication into your app using Cloud Code.</h1>
<p><em>If you are not familiar with implementing Cloud Code into your private GitHub repo, you can follow our <a href="https://blog.sashido.io/sashidos-getting-started-guide/#yourbusinesslogicakacloudcode">Getting Started</a> guide for a seamless setup.</em></p>
<h3 id="setupyourdatabaseandtwilio">Set up your Database and Twilio</h3>
<p>First and foremost, to avoid database-related errors you have to complete a few steps:<br>
1. Navigate to your SashiDo app’s <strong>Dashboard</strong> &gt; <strong>Core</strong> &gt; <strong>Browser</strong>  &gt; <strong>User</strong>. Select “<strong>Edit</strong>” from the top-right menu and click on “<strong>Add a new column</strong>”.<br>
2. Create two database <strong>String</strong> fields called “<strong>phone_number</strong>” and “<strong>From</strong>” inside your User class.</p>
<p><img src="https://media-blog.sashido.io/content/images/2023/08/create_class.gif" alt="Implementing Two-factor Authentication like a Pro"></p>
<p>Now that you have set up your database, you will need an SMS provider to send the authentication codes. We’ve chosen <a href="https://www.twilio.com/en-us">Twilio</a> for the job. It is a cloud communications platform that allows software developers programmatically to make and receive phone calls, send and receive text messages, and perform other communication functions using web service APIs.</p>
<p>To get started, you just need to <a href="https://www.twilio.com/try-twilio">create an account in Twilio</a>. As soon as your account is completed, you will be redirected to its Dashboard where you will find 3 keys that you need to implement into your Cloud Code: <strong>Auth Token</strong>*, <strong>Account SID</strong>* &amp; <strong>Trial number</strong>*. Store the keys into a secure location. If you’d like to, you can store them as <a href="https://blog.sashido.io/announcing-environment-variables/">environment variables in your SashiDo app</a>.</p>
<h3 id="addthecodetoyourcloudcode">Add the code to your Cloud Code</h3>
<p>Take a look at the code you need to implement. Firstly, you need to require the “<strong>crypto</strong>” module to generate random bytes from which a unique verification code will be created.</p>
<pre><code class="language-js">const crypto = require('crypto');
</code></pre>
<p>Afterwards, define the symbols that can be used to create the unique code.</p>
<pre><code class="language-js">const availableCharacters =
   'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
</code></pre>
<p>Now you need to add the Twilio verification codes that you got when you created your account.</p>
<pre><code class="language-js">const accountSid = process.env.TWILLIO_ACCOUNT_SID || 'Account SID';
const authToken = process.env.TWILLIO_AUTH_TOKEN || 'Auth Token';
const twillio = require('twilio')(accountSid, authToken);

const TWILLIO_FROM_NUMBER = process.env.TWILLIO_FROM_NUMBER || 'Trial Number';
</code></pre>
<p>Once you’re done with the above-mentioned steps, you can add the function that will generate a random 6-digit code. It does this by accumulating random bytes and mapping them to characters from a predefined set. The resulting code is returned as a string.</p>
<pre><code class="language-js">function generateCode() {
   const codeLength = 6;

   const bytes = crypto.randomBytes(codeLength);
   const code = new Array(codeLength);

   let cursor = 0;
   for (i = 0; i &lt; bytes.length; i++) {
       cursor += bytes[i];
       code[i] = availableCharacters.charAt(
           cursor % availableCharacters.length
       );
   }

   return code.join('');
}
</code></pre>
<p>You can now create a cloud function named &quot;<strong>login</strong>&quot; that handles user login.</p>
<pre><code class="language-js">Parse.Cloud.define('login', async request =&gt; {
   const { username, password, code } = request.params;
   const user = await Parse.User.logIn(username, password);
</code></pre>
<p>Using a conditional statement, the following code checks if the user has a 6-digit authentication code and if they don’t have it, it will generate it for them.</p>
<pre><code class="language-js">if (!code) {
       const generatedCode = generateCode();
       user.set('code_2fa', generatedCode);
       await user.save(null, { useMasterKey: true });
       await twillio.messages.create({
           body: `Your 2FA code is ${generatedCode}`,
           from: TWILLIO_FROM_NUMBER,
           to: user.get('phone_number')
       });
</code></pre>
<p>The conditional statement then check if the generated code and the one that’s been entered by the user are the same. If they aren’t, it will throw an error and won’t allow the user to sign in.</p>
<pre><code class="language-js">} else if (code &amp;&amp; user.get('code_2fa') !== code) {
       throw new Error('Invalid 2fa code');
   } else {
       user.unset('code_2fa');
       await user.save(null, { useMasterKey: true });
       return {
           sessionToken: user.getSessionToken()
       };
   }
});
</code></pre>
<p>The upload itself will trigger a <a href="https://blog.sashido.io/manage-and-keep-track-of-your-builds-and-deployments/">build &amp; deploy</a> on your application. Once they are successfully completed it is time to actually test if everything works as it should.</p>
<p>To verify the process was a success you can create an <a href="https://blog.sashido.io/introducing-the-api-console/">API POST</a> request calling the function. In this example, my username &amp; password are both “123”. Then press “Send Query”.</p>
<p><strong>Note</strong>: Make sure your user already has a phone number stored in “phone_number” in your database. Otherwise, you’ll get an error.</p>
<p><img src="https://media-blog.sashido.io/content/images/2023/08/API-console-2.png" alt="Implementing Two-factor Authentication like a Pro"></p>
<p>As soon as you execute the query, you will receive an SMS.<br>
<img src="https://media-blog.sashido.io/content/images/2023/08/2fa-code.png" alt="Implementing Two-factor Authentication like a Pro"></p>
<p>Now let’s give it a try inside a web browser for example. The front-end is connected to the code and the Submit button triggers the login function. The username &amp; password are the same as the example above (123 &amp; 123).</p>
<p><img src="https://media-blog.sashido.io/content/images/2023/08/sashido-login.png" alt="Implementing Two-factor Authentication like a Pro"></p>
<p>Once you click on the “Submit” button, the function is checking the username and password and if they are correct, a code is being generated to your phone as an SMS.</p>
<p><img src="https://media-blog.sashido.io/content/images/2023/08/2fa-code-2.png" alt="Implementing Two-factor Authentication like a Pro"></p>
<p>Now let’s get the code and type it into our 2fa code field.</p>
<p><img src="https://media-blog.sashido.io/content/images/2023/08/code-field.png" alt="Implementing Two-factor Authentication like a Pro"></p>
<p>There are 2 possible outcomes. If the code is correct, we will be granted access, if it is wrong we will be denied access.</p>
<p><img src="https://media-blog.sashido.io/content/images/2023/08/result-popup.png" alt="Implementing Two-factor Authentication like a Pro"></p>
<h1 id="conclusion">Conclusion</h1>
<p>Two-Factor Authentication (2FA) is a crucial security measure that adds an extra layer of protection to online accounts. By requiring users to provide two different authentication factors, such as a password and a one-time verification code, 2FA significantly enhances account security. With the ever-increasing cyber threats, implementing 2FA has become essential to safeguarding sensitive data and preventing unauthorized access. Embracing 2FA helps users stay one step ahead of potential attackers and creates a safer digital environment for online interactions.</p>
</div>]]></content:encoded></item><item><title><![CDATA[Effortlessly generate PDF files with ChatGPT]]></title><description><![CDATA[In this tutorial, we'll show you how to create PDF files with the PDFKit library from data stored in a SashiDo app’s DB with ChatGPT. We’ll go through the DB setup, the ChatGPT prompt and code, and the next steps.]]></description><link>https://blog.sashido.io/effortlessly-generate-pdf-files-with-chatgpt/</link><guid isPermaLink="false">64b9102829cfdf0022b3da56</guid><category><![CDATA[Files]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[ChatGPT]]></category><dc:creator><![CDATA[Izabel Vasilyovska]]></dc:creator><pubDate>Mon, 24 Jul 2023 09:43:33 GMT</pubDate><media:content url="https://media-blog.sashido.io/content/images/2023/07/cover-3--1-.png" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://media-blog.sashido.io/content/images/2023/07/cover-3--1-.png" alt="Effortlessly generate PDF files with ChatGPT"><p>In this tutorial, we will show you how to generate PDF reports from data stored in a <a href="https://blog.sashido.io/sashidos-getting-started-guide/#manageyourdatabaselikeapro">SashiDo app’s database</a> and the <a href="https://pdfkit.org/docs/getting_started.html">PDFKit</a> library. We’ll go through the database setup, the prompt we used in ChatGPT, the code snippet ChatGPT wrote for us, and what are the next steps. Let’s get started!</p>
<p>You can watch our short video tutorial and if you’d like a more detailed explanation, continue reading.</p>
<iframe width="854" height="480" src="https://www.youtube.com/embed/zBMnpCTd0rg" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
<h1 id="setupyourdatabase">Set Up Your Database</h1>
<p><img src="https://media-blog.sashido.io/content/images/2023/07/database-structure.png" alt="Effortlessly generate PDF files with ChatGPT"><br>
<em>Diagram of the “movieData” class structure</em></p>
<p>For the purpose of this tutorial, we’ll need to create a new class called “<strong>movieData”</strong> in your database. You can do that from your app’s <strong>Dashboard</strong> &gt; <strong>Core</strong> &gt; <strong>Browser</strong> &gt; <strong>Create a class</strong>.<br>
Once you have your class, you can add the columns from the Dashboard by clicking on <strong>Add a new column</strong> and afterwards adding the data row by row.</p>
<p>You can also add the data using our <a href="https://blog.sashido.io/introducing-the-api-console/">REST API</a> console that you can find in <strong>Core</strong> &gt; <strong>API Console</strong>. From there, using the <a href="https://docs.parseplatform.org/rest/guide/#batch-operations">batch endpoint</a>, you can add multiple rows of data. There’s also no need to create the columns beforehand. MongoDB automatically creates them when a column is missing.</p>
<h1 id="theprompt">The Prompt</h1>
<p>When it comes to using ChatGPT for coding tasks, providing clear and concise instructions is essential for effective communication. By following the 4 guidelines below, we optimized our interactions with ChatGPT and improved the quality of the assistance the tool provided.</p>
<h4 id="1clearlydefineyourobjective">1. Clearly Define Your Objective</h4>
<p>Before engaging with ChatGPT, it is crucial to have a clear understanding of your task. Take the time to define your objective and outline the specific problem or code-related challenge you need assistance with. By articulating your requirements, you can provide precise instructions to ChatGPT, increasing the likelihood of receiving relevant and helpful responses.</p>
<h4 id="2bedirectandconcise">2. Be Direct and Concise</h4>
<p>When formulating your prompts, it is important to get straight to the point. Avoid including unnecessary information or context that is not directly relevant to the task. By keeping your prompts concise and focused, you provide ChatGPT with a clear direction, reducing the chances of confusion.</p>
<h4 id="3breakdowntasksintomanageablesteps">3. Break Down Tasks into Manageable Steps</h4>
<p>While ChatGPT is a powerful tool, it is not optimized for generating code for complex and large-scale projects. To make the most of its capabilities, it is advisable to break down your coding tasks into smaller, manageable steps. By dividing your problem into bite-size pieces, you can effectively utilize ChatGPT's assistance for specific aspects of your coding challenge.</p>
<h4 id="4providesufficientcontext">4. Provide Sufficient Context</h4>
<p>To ensure accurate and relevant responses from ChatGPT, you need to provide sufficient context in your prompts. Explain the problem statement, any relevant input/output examples, and any constraints or requirements that the solution should adhere to.</p>
<p>Here is the prompt we used for the purposes of this tutorial. It’s quite short and follows the 4 guidelines above.</p>
<blockquote>
<p>I have a SashiDo app that uses Parse Server Version 3.1.3. In my database, I have a class named &quot;movieData&quot;. It has the following columns: movieTitle, releaseDate, review, rating.<br>
Write code that fetches the data from movieData and generates a pdf file with it.<br>
Write the code in such a matter so that I won't need to edit it.</p>
</blockquote>
<h1 id="connectyouraccounttogithub">Connect Your Account to GitHub</h1>
<p>Before we get to the code, you need to set up our development environment. With every SashiDo app, you get a free private GitHub repo where you have full access to your business logic, a.k.a your Cloud Code. So, to set up a dev environment, you’ll first need to link your GitHub and SashiDo accounts. If you’ve already done this, you can skip this step. For those who haven’t, you can connect your GitHub account to SashiDo from your app’s <strong>Dashboard</strong> &gt; <strong>Core</strong> &gt; <strong>Cloud Code</strong> &gt; <strong>Start your Cloud Code</strong>.</p>
<p><img src="https://media-blog.sashido.io/content/images/2023/07/Screenshot-2023-07-20-150624.png" alt="Effortlessly generate PDF files with ChatGPT"></p>
<p>If you aren't familiar with Cloud Code, we recommend watching our <a href="https://www.youtube.com/watch?v=Wm8wv3biWkc&amp;t=64s">YouTube video tutorial</a> on the topic, as well as going through <a href="https://docs.parseplatform.org/cloudcode/guide/">Parse’s Cloud Code documentation</a>.</p>
<h1 id="setupalocaldevelopmentenvironment">Set Up a Local Development Environment</h1>
<p>Once you’ve connected your GitHub and SashiDo accounts, you just need to head over to your private GitHub repo from your app’s <strong>Dashboard</strong> &gt; <strong>Core</strong> &gt; <strong>Cloud Code</strong> &gt; <strong>Manage on GitHub</strong>.</p>
<p><img src="https://media-blog.sashido.io/content/images/2023/07/Untitled-design-1.png" alt="Effortlessly generate PDF files with ChatGPT"></p>
<p>There you will find the <strong>README.md</strong> with instructions. We’ve also prepared a very detailed tutorial about creating a <a href="https://blog.sashido.io/creating-a-development-environment/">local development environment</a> from scratch. We recommend checking it out, as well.</p>
<h1 id="resultsandtesting">Results and Testing</h1>
<p>Now that we’ve set up our local development environment, let’s see the code ChatGPT wrote for us.</p>
<p>Now that we’ve set up our local development environment, let’s see the code ChatGPT wrote for us.</p>
<pre><code class="language-js">const Parse = require('parse/node');
const PDFDocument = require('pdfkit');
const fs = require('fs');

// Initialize Parse with your SashiDo app credentials
Parse.initialize('YOUR_APPLICATION_ID', 'YOUR_JAVASCRIPT_KEY');
Parse.serverURL = 'https://YOUR_PARSE_SERVER_URL/parse';

// Create a new PDF document
const doc = new PDFDocument();

// Fetch data from the &quot;movieData&quot; class
const MovieData = Parse.Object.extend('movieData');
const query = new Parse.Query(MovieData);
query.limit(1000); // Set a limit to the number of results to fetch

query.find()
  .then((results) =&gt; {
    // Loop through the fetched movieData objects
    results.forEach((movie) =&gt; {
      const movieTitle = movie.get('movieTitle');
      const releaseDate = movie.get('releaseDate');
      const review = movie.get('review');
      const rating = movie.get('rating');

      // Write the movie data to the PDF document
      doc.text(`Title: ${movieTitle}`);
      doc.text(`Release Date: ${releaseDate}`);
      doc.text(`Review: ${review}`);
      doc.text(`Rating: ${rating}`);
      doc.moveDown(); // Move down to the next line
    });

    // Save the PDF document to a file
    doc.pipe(fs.createWriteStream('movieData.pdf'));
    doc.end();

    console.log('PDF file generated successfully!');
  })
  .catch((error) =&gt; {
    console.error('Error fetching movieData:', error);
  });
</code></pre>
<p>In summary, the code snippet fetches the movieData objects from the &quot;movieData&quot; class and iterates through them. It extracts the relevant data, such as movie title, release date, review, and rating, and writes them to a PDF document using PDFKit. Finally, it saves the generated PDF file in the current directory.</p>
<p>You can insert this code into the <strong>functions.js</strong> file or into a separate one. Once you’ve done this, you just have to do two things:</p>
<ol>
<li>Install the NPM modules – <a href="https://www.npmjs.com/package/pdfkit">pdfkit</a> and <a href="https://www.npmjs.com/package/fs">fs</a>. I used the following command to install both:  npm i pdfkit fs</li>
<li>Initialize your Parse Server – you can find your credentials in your app’s <strong>Dashboard</strong> &gt; <strong>App Settings</strong> &gt; <strong>Security &amp; Keys</strong>. From there you’ll just need your Application ID, JavaScript Key, and your API URL Address.</li>
</ol>
<p><img src="https://media-blog.sashido.io/content/images/2023/07/credentials.png" alt="Effortlessly generate PDF files with ChatGPT"></p>
<p>After you’re done with these steps, you can run the code and see that your pdf file was created in your local directory.</p>
<p>You shouldn’t stop here and deploy your code to production. We always recommend testing code before deploying it. This is a crucial step for ensuring reliable software performance, minimizing the risk of glitches, and providing a positive user experience.</p>
<p>We haven’t included specific tests in this tutorial because every app is different and what works for one, might not work for another. Take your time to thoroughly test your code to ensure it doesn’t create any problems with your existing app.</p>
<h1 id="nextsteps">Next Steps</h1>
<p>After you’re done testing and you’re satisfied with the results, you just need to commit the changes to your GitHub repo. I did this by running the following command: <code>git commit -m &quot;write to pdf functionality&quot;</code> and afterwards pushing the changes to the master branch with <code>git push</code>. This will cause your app to <a href="https://blog.sashido.io/manage-and-keep-track-of-your-builds-and-deployments/">build and deploy</a> automatically.</p>
<p><img src="https://media-blog.sashido.io/content/images/2023/07/cloud-code.png" alt="Effortlessly generate PDF files with ChatGPT"></p>
<p>After a few minutes, your app will be running with the latest changes you pushed.</p>
<h1 id="conclusion">Conclusion</h1>
<p>In this tutorial, we explored how to leverage ChatGPT’s code-writing capabilities to quickly add new features to your apps and save time and effort. The code snippet in this tutorial is fairly simple but you can pull off more challenging use cases. The trick is in giving ChatGPT a simple prompt and asking short follow-up questions.</p>
<p>We’d be happy to hear how you’ve leveraged ChatGPT in your professional life and what positive effects it had on you.</p>
<p>Happy coding!</p>
</div>]]></content:encoded></item></channel></rss>