<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mariano Pardo</title>
    <description>The latest articles on DEV Community by Mariano Pardo (@marian2js).</description>
    <link>https://dev.to/marian2js</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F233419%2Ff1bd526f-fa46-4199-810f-2eabf1110f90.jpg</url>
      <title>DEV Community: Mariano Pardo</title>
      <link>https://dev.to/marian2js</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/marian2js"/>
    <language>en</language>
    <item>
      <title>How to send metrics to AWS CloudWatch when an event happens on a Smart Contract</title>
      <dc:creator>Mariano Pardo</dc:creator>
      <pubDate>Wed, 24 Aug 2022 13:37:00 +0000</pubDate>
      <link>https://dev.to/marian2js/how-to-send-metrics-to-aws-cloudwatch-when-an-event-happens-on-a-smart-contract-2p9n</link>
      <guid>https://dev.to/marian2js/how-to-send-metrics-to-aws-cloudwatch-when-an-event-happens-on-a-smart-contract-2p9n</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/r_xEBrVKXdo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=r_xEBrVKXdo"&gt;https://www.youtube.com/watch?v=r_xEBrVKXdo&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What you’ll learn
&lt;/h2&gt;

&lt;p&gt;You will learn how to create a workflow that triggers every time an event happens in a smart contract on any EVM network.&lt;br&gt;
When the workflow is triggered, we will send metrics to AWS CloudWatch Metrics with information from the event.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tools used
&lt;/h2&gt;

&lt;p&gt;ChainJet: &lt;a href="https://chainjet.io"&gt;https://chainjet.io&lt;/a&gt;&lt;br&gt;
AWS CloudWatch Metrics: &lt;a href="https://aws.amazon.com/cloudwatch"&gt;https://aws.amazon.com/cloudwatch&lt;/a&gt;&lt;/p&gt;

</description>
      <category>web3</category>
      <category>blockchain</category>
      <category>nocode</category>
      <category>ethereum</category>
    </item>
    <item>
      <title>How to build a No-Code backend for a Link Sharing app with GraphQL and Rest API support</title>
      <dc:creator>Mariano Pardo</dc:creator>
      <pubDate>Tue, 21 Apr 2020 17:13:30 +0000</pubDate>
      <link>https://dev.to/marian2js/how-to-build-a-no-code-backend-for-a-link-sharing-app-with-graphql-and-rest-api-support-1d67</link>
      <guid>https://dev.to/marian2js/how-to-build-a-no-code-backend-for-a-link-sharing-app-with-graphql-and-rest-api-support-1d67</guid>
      <description>&lt;p&gt;In this post I want to show how to build a production ready-backend for a Link Sharing application in just minutes, without writing a single line of code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Functional requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  Users can create accounts using email and password or using social networks (Google, Facebook or GitHub).&lt;/li&gt;
&lt;li&gt;  Authenticated users can submit links with a title and a description.&lt;/li&gt;
&lt;li&gt;  Authenticated users can update or delete their own submissions.&lt;/li&gt;
&lt;li&gt;  Authenticated users can upvote or downvote any link.&lt;/li&gt;
&lt;li&gt;  Authenticated users can comment on any link.&lt;/li&gt;
&lt;li&gt;  Authenticated users can update or delete their own comments.&lt;/li&gt;
&lt;li&gt;  Authenticated users can upvote or downvote any comment.&lt;/li&gt;
&lt;li&gt;  The vote results (number of upvotes - number of downvotes) must automatically be kept up to date on links and comments.&lt;/li&gt;
&lt;li&gt;  After sign up, users should receive an email for verifying their email address and also a welcome email. Users can also request a password recovery email.&lt;/li&gt;
&lt;li&gt;  Authenticated users can update their email and password.&lt;/li&gt;
&lt;li&gt;  The system can be controlled using GraphQL and/or a Rest API.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For creating this application we will use  &lt;strong&gt;&lt;a href="https://commun.dev/"&gt;Commun&lt;/a&gt;&lt;/strong&gt;  an Open Source No-Code platform for creating scalable backends for communities and user based apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  System Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://nodejs.org/en/download/"&gt;Node.js&lt;/a&gt;  version &amp;gt;= 12 (can be checked with  &lt;code&gt;node -v&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://docs.mongodb.com/manual/installation/"&gt;MongoDB&lt;/a&gt;  version &amp;gt;= 3.6 (can be checked with  &lt;code&gt;mongo --version&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Create an empty project
&lt;/h2&gt;

&lt;p&gt;The fastest way to bootstrap a new project is using the  &lt;code&gt;npx&lt;/code&gt;  tool which is included with node:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-commun-app my-app
cd my-app
npm start

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the installation is completed your application should be running and you should see an output similar to this one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;🚀 development server started at http://localhost:3000

    🎩‍ Admin dashboard: http://localhost:3000/dashboard

    💪 API endpoint: http://localhost:3000/api/v1/:entity

    🔑 Register your first admin account: http://localhost:3000/dashboard/signup?code=3d91c05d81b8cdf18997b1d07c6529e9eec3

    👌 GraphQL endpoint: http://localhost:3000/graphql

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's follow the link to register an admin account. This account will only exist in your local environment. You should see a screen like this one:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YWF7RRfe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--D61rjL1c--/c_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pm24q3exv3yob8rpd826.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YWF7RRfe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--D61rjL1c--/c_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pm24q3exv3yob8rpd826.png" alt="Register an admin account on Commun" width="880" height="1013"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After you completed the required information, your account will be created and you will have access to your dashboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Qz18X8pI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--qXt9VDOX--/c_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9kycggjcs0glcrgi7o9h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Qz18X8pI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--qXt9VDOX--/c_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9kycggjcs0glcrgi7o9h.png" alt="Commun Dashboard" width="880" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create entities
&lt;/h2&gt;

&lt;p&gt;Entities represent the components of your application. For this application we will need to create the entities  &lt;strong&gt;Links&lt;/strong&gt;,  &lt;strong&gt;Comments&lt;/strong&gt;,  &lt;strong&gt;LinkVotes&lt;/strong&gt;  and  &lt;strong&gt;CommentVotes&lt;/strong&gt;. The entity  &lt;strong&gt;Users&lt;/strong&gt;  exists by default.&lt;/p&gt;

&lt;h3&gt;
  
  
  Links Entity
&lt;/h3&gt;

&lt;p&gt;On the left sidebar on your dashboard, click on  &lt;em&gt;Add entity&lt;/em&gt;. Enter the name  &lt;code&gt;links&lt;/code&gt;  and select the checkbox  &lt;code&gt;Users can create Links&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;After the entity is created, you need to add an attribute for each value a link can have.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Add an attribute with key  &lt;code&gt;link&lt;/code&gt;  and type  &lt;code&gt;String&lt;/code&gt;. Check the required and unique checkboxes to ensure each link can only be submitted once.&lt;/li&gt;
&lt;li&gt; Add an attribute with key  &lt;code&gt;title&lt;/code&gt;  and type  &lt;code&gt;String&lt;/code&gt;. Check the required checkbox to ensure all links will have a title. Set a maximum length of 150 characters.&lt;/li&gt;
&lt;li&gt; Add an attribute with key  &lt;code&gt;description&lt;/code&gt;  and type  &lt;code&gt;String&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; Add an attribute with key  &lt;code&gt;slug&lt;/code&gt;, type  &lt;code&gt;Slug&lt;/code&gt;  and set from  &lt;code&gt;title&lt;/code&gt;. This will automatically create an URL friendly slug from your title. Select the required, unique and read only checkboxes to ensure the slug cannot be changed and it is unique.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Comments Entity
&lt;/h3&gt;

&lt;p&gt;Create a new entity with the name  &lt;code&gt;comments&lt;/code&gt;  and select the checkbox  &lt;code&gt;Users can create Comments&lt;/code&gt;. Then add the following attributes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Attribute with key  &lt;code&gt;body&lt;/code&gt;  and type  &lt;code&gt;String&lt;/code&gt;, which will contain the text of the comment.&lt;/li&gt;
&lt;li&gt; Attribute with key  &lt;code&gt;link&lt;/code&gt;  and type  &lt;code&gt;Entity Reference&lt;/code&gt;. Select  &lt;code&gt;Links&lt;/code&gt;  on the entity reference selector, this attribute will only accept the ID of a link. Then check the index checkbox, which will allow you to efficiently return all the comments for a given link. Last, check the required and read only checkboxes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Link Votes
&lt;/h3&gt;

&lt;p&gt;Create a new entity with name  &lt;code&gt;linkVotes&lt;/code&gt;  and select the checkbox  &lt;code&gt;Users can create LinkVotes&lt;/code&gt;. Then add the following attributes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Attribute with key  &lt;code&gt;link&lt;/code&gt;, type  &lt;code&gt;Entity Reference&lt;/code&gt;  and entity reference  &lt;code&gt;Links&lt;/code&gt;. Check the required and read only checkboxes.&lt;/li&gt;
&lt;li&gt; Attribute with key  &lt;code&gt;value&lt;/code&gt;  and type  &lt;code&gt;Enum&lt;/code&gt;. On the list of accepted values add  &lt;code&gt;1&lt;/code&gt;  and  &lt;code&gt;-1&lt;/code&gt;, both with type  &lt;code&gt;Number&lt;/code&gt;. This attribute will only accept these values, which represent an upvote and downvote respectively. Then check the required and read only checkboxes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Ensuring an user can only vote a link once
&lt;/h4&gt;

&lt;p&gt;In order to ensure that an user can only vote a link once, we need to create an index on the entity. Go to the indexes section and click &lt;em&gt;add index&lt;/em&gt;. On the index keys select  &lt;code&gt;user&lt;/code&gt;  and  &lt;code&gt;link&lt;/code&gt;, both with type  &lt;code&gt;Ascending&lt;/code&gt;. Then select the unique checkbox.&lt;/p&gt;

&lt;h4&gt;
  
  
  Keeping the vote results up to date.
&lt;/h4&gt;

&lt;p&gt;In order to keep the vote results (number of upvotes - number of downvotes) up to date, you need to follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Go to the  &lt;code&gt;Links&lt;/code&gt;  entity and add a new attribute with key  &lt;code&gt;votes&lt;/code&gt;, type  &lt;code&gt;Number&lt;/code&gt;  and default value  &lt;code&gt;0&lt;/code&gt;. Then under Attribute Permissions, for create and update permissions select  &lt;code&gt;Only the system&lt;/code&gt;. This will ensure that users cannot modify the number of votes on a link.&lt;/li&gt;
&lt;li&gt; Go back to the  &lt;code&gt;LinkVotes&lt;/code&gt;  entity and open the Hooks section.

&lt;ol&gt;
&lt;li&gt; Add a new hook with lifecycle  &lt;code&gt;After Create&lt;/code&gt;, action  &lt;code&gt;Increment&lt;/code&gt;,  target &lt;code&gt;this.link.votes&lt;/code&gt;  and increment by  &lt;code&gt;{this.value}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; Add a new hook with lifecycle  &lt;code&gt;After Delete&lt;/code&gt;, action  &lt;code&gt;Increment&lt;/code&gt;, target  &lt;code&gt;this.link.votes&lt;/code&gt;  and increment by  &lt;code&gt;{-this.value}&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Comment Votes
&lt;/h3&gt;

&lt;p&gt;Creating comment votes is almost identical to creating link votes. Create a new entity with the name  &lt;code&gt;commentVotes&lt;/code&gt;  and select the checkbox  &lt;code&gt;Users can create CommentVotes&lt;/code&gt;. Then follow the same steps as for Link Votes, but using the  &lt;code&gt;Comments&lt;/code&gt;  entity instead of the  &lt;code&gt;Links&lt;/code&gt;  entity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use your APIs
&lt;/h2&gt;

&lt;p&gt;Your application is now complete. GraphQL and Rest APIs are ready to use.&lt;/p&gt;

&lt;h3&gt;
  
  
  GraphQL
&lt;/h3&gt;

&lt;p&gt;You can open a GraphQL Explorer by going to the GraphQL link on the left sidebar. The explorer includes documentation for the supported queries and mutations.  &lt;a href="https://commun.dev/docs/graphql"&gt;Read Commun GraphQL documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The endpoint for GraphQL is  &lt;code&gt;http://localhost:3000/graphql&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rest API
&lt;/h3&gt;

&lt;p&gt;You can find the documentation for the API on:  &lt;a href="https://commun.dev/docs/rest-api"&gt;https://commun.dev/docs/rest-api&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The endpoint for the Rest API is  &lt;code&gt;http://localhost:3000/api/v1/:entity&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Social Authentication
&lt;/h2&gt;

&lt;p&gt;On the left sidebar click on Users. Check the social authentication methods you want to allow and set your client ID and secret keys for each one. You must provide a callback url on your frontend which will complete the authentication. The supported services are: Google, Facebook and GitHub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pushing your chances
&lt;/h2&gt;

&lt;p&gt;After your application is ready, just push the changes to your source control system. All the configuration created by Commun is stored in JSON files that should be pushed to your source control system. The application can be deployed in the same way as any Node application, no special configurations are needed. The app can be started on production by running:  &lt;code&gt;npm run start:production&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>restapi</category>
      <category>nocode</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
