<?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 Matteo Lobello on Medium]]></title>
        <description><![CDATA[Stories by Matteo Lobello on Medium]]></description>
        <link>https://medium.com/@matteolobello?source=rss-fd796195ca5e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FISa3ZYDkgpx_UWbO_4Kgw.jpeg</url>
            <title>Stories by Matteo Lobello on Medium</title>
            <link>https://medium.com/@matteolobello?source=rss-fd796195ca5e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 20:09:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@matteolobello/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[Top Platforms to launch your next SaaS Project]]></title>
            <link>https://itnext.io/top-platforms-to-launch-your-next-saas-project-9a563b5ae766?source=rss-fd796195ca5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a563b5ae766</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[edge-computing]]></category>
            <dc:creator><![CDATA[Matteo Lobello]]></dc:creator>
            <pubDate>Wed, 17 Nov 2021 20:42:44 GMT</pubDate>
            <atom:updated>2021-11-18T14:33:16.368Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HYAd1aal5Et1A-Qzs6VAtQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@nasa">NASA</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><p>Deploying a full-stack application is no easy job. You have to deal with scalability, syncing the state between multiple nodes, having a robust database with backups and replicas, avoiding vendor lock-in and handle many other issues that might happen as the project grows.</p><p>This table makes the design of your multi-tier architecture easier by listing the most modern solutions to easily ship a project at scale.</p><p>Feel free to combine multiple services together to get the best of all the platforms. :-)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/742b07c1fcffcd909ace0137103f50d4/href">https://medium.com/media/742b07c1fcffcd909ace0137103f50d4/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a563b5ae766" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/top-platforms-to-launch-your-next-saas-project-9a563b5ae766">Top Platforms to launch your next SaaS Project</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UI-Testing TypeScript React apps with Puppeteer and Jest]]></title>
            <link>https://itnext.io/ui-testing-typescript-react-apps-with-puppeteer-and-jest-a48684f5d8dc?source=rss-fd796195ca5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a48684f5d8dc</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[puppeteer]]></category>
            <category><![CDATA[jest]]></category>
            <dc:creator><![CDATA[Matteo Lobello]]></dc:creator>
            <pubDate>Mon, 03 May 2021 17:29:10 GMT</pubDate>
            <atom:updated>2021-05-12T16:55:08.601Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article I’d like to show you how to correctly configure Puppeteer in your React project.</p><p>Puppeteer is a library developed by Google that helps us to make UI testing way easier.</p><p>First of all, let’s start by creating a simple new app by running the create-react-app package.</p><p>$ npx create-react-app my-app --template typescript</p><p>This is our simple app:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ZSDTKk9AGk8r7_6vkVsIg.png" /><figcaption>App.tsx</figcaption></figure><p>Of course, we need to install some dev-dependencies:</p><p>$ npm i -D jest puppeteer start-server-and-test ts-jest ts-node @types/jest @types/puppeteer</p><p>Now, we can setup Jest.<br>Create a new file in the root path of the project called “jest.config.ts”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BU0yXo6wexXiilgPTYwoKA.png" /><figcaption>jest.config.ts</figcaption></figure><p>Make a new folder in the “src” folder called “__tests__”: this is where all our tests will be located.<br>In this folder, let’s create our first test file called “App.test.ts”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZhEpKJGRe7ZbrGLAxvJVQ.png" /><figcaption>App.test.ts</figcaption></figure><p>This script will:</p><ol><li>Launch a new Chromium instance in headless (“invisible”) mode (built-in the Puppeteer package)</li><li>Create a new tab that points to our local development server</li><li>Click the “increase counter” button 10 times</li><li>Check if the value of our counter is 10</li><li>Close the browser instance</li></ol><p>Before launching our tests, we need to wait for our local server to be up and running.</p><p>This is where the start-server-and-test library comes to the rescue.</p><p>Open “package.json”:</p><ol><li>replace the old &quot;test&quot;: &quot;react-scripts test” with &quot;test&quot;: &quot;jest”</li><li>add &quot;ci&quot;: &quot;BROWSER=none PORT=3000 start-server-and-test start <a href="http://localhost:3000/">http://localhost:3000</a> test&quot;</li></ol><p>Note that the BROWSERproperty is set to none so that we don’t open our browser when launching the development React server.</p><p>We’re finally ready to test our app:</p><p>$ npm run ci</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JZAnbrj-kRUuOBVVeLsjeQ.png" /></figure><p>If we want to have more visual feedback, we can turn off the headless mode.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F544659072%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=http%3A%2F%2Fvimeo.com%2F544659072&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2Fdefault_960&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1152" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/137013b67ad05b721f1594d75e72cca1/href">https://medium.com/media/137013b67ad05b721f1594d75e72cca1/href</a></iframe><p>You can find the code on GitHub <a href="https://gist.github.com/matteolobello/a6a9d29bccca4438b0b3b80730da5576">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a48684f5d8dc" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/ui-testing-typescript-react-apps-with-puppeteer-and-jest-a48684f5d8dc">UI-Testing TypeScript React apps with Puppeteer and Jest</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding React]]></title>
            <link>https://itnext.io/understanding-react-%EF%B8%8F-3bc9589ab166?source=rss-fd796195ca5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bc9589ab166</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Matteo Lobello]]></dc:creator>
            <pubDate>Mon, 26 Apr 2021 18:12:14 GMT</pubDate>
            <atom:updated>2021-05-12T16:56:28.773Z</atom:updated>
            <content:encoded><![CDATA[<p>React is one of the most modern solutions to build web applications.<br>In this article, I’d like to summarise in a practical way the peculiarities of this framework.</p><h3><strong>Let’s create a new React project</strong></h3><p>First, make sure you have Node and its package manager (NPM) installed.<br>Then, open a new terminal:</p><ol><li>Install the create-react-app package globally<br>$ npm install -g create-react-app</li><li>Create the React app folder template<br>$ create-react-app my-awesome-app</li></ol><p>➡ Note: you can execute create-react-app without installing it via NPX:<br>$ npx create-react-app my-awesome-app</p><p>Now we have our project folder ready.<br>It contains several packages, you can see what’s included <a href="https://github.com/facebook/create-react-app#whats-included">here</a>.</p><h3><strong>Let’s get started</strong></h3><p>Before getting to the code, there are some things you should know about how React works.</p><p>First of all, React uses a language called JSX, which is basically a way to write HTML in JavaScript files.</p><p>In React pretty much everything is a component.<br>A component is a single unit that renders HTML code.<br>A component can contain more components, for example:<br>=&gt; Home Screen Component <br>==&gt; Navigation Bar Component<br>====&gt; Logo Component<br>====&gt; Links Component<br>==&gt; Content Component<br>==&gt; …and so on</p><p>There are two types of components, functional components and class components. Generally speaking, functional components are easier to use and more modern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*anLJg-deB1nLss1AIgJ1sw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*5_SarLFP-hQfV-coIO7Q8w.png" /><figcaption>Class Component (First image) — Functional Component (Second image)</figcaption></figure><p>React works on the Virtual DOM.</p><p>In case you don’t know it, the DOM (Document Object Model) in plain JavaScript is the representation of the elements of a web page and contains all the methods you need to update the user interface.</p><p>Thanks to the Virtual DOM, React can optimise the UI renders, updating only the elements that need to be updated.</p><h3>Project Structure</h3><p>Open the project with Visual Studio Code (of course, you can use any other editor).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hxBrh-pc1pxqKWhmTI9skw.png" /></figure><p>As you can see, there are three folders:</p><ol><li>🟥 “node_modules”, where all our libraries get installed</li><li>🟩 “public”, the HTML template in which React will be rendered</li><li>🟦 “src”, the source files of our project</li></ol><p>The entry point of our app is inside the “index.js” file.</p><p>This file is the root of the project and contains the App component, located inside the “App.js” file.</p><p>To run the app, you can use the integrated terminal is Visual Studio Code, going to the menu bar, “Terminal”, “New Terminal”.<br>Now, type:<br>$ npm start <br>This will execute the script named start (located inside the scriptsobject of our package.json file) in a Node.js environment.</p><p>➡ Note: hot-reloading is enabled in debug mode. As soon as you edit and save a file, React will reload the browser tab for you.</p><h3><strong>Creating our SpaceX launches dashboard</strong></h3><p>In this sample project we will create a simple web application that shows the list of SpaceX launches, getting the data from <a href="https://api.spacexdata.com/">https://api.spacexdata.com</a>.</p><p>Open “App.js” and remove everything, leaving just a simple component with a title.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sfAgh-vzhiCXWrP74M_cjg.png" /></figure><p>Now, let’s create our first <em>stateful</em> variable.</p><p>The state is an object that holds everything that can change during the lifetime of our component.<br>To create a state variable, we use the useState hook function included in the React package.<br>useState can have an optional argument, which represents its own default value.<br>It returns an array of two items:</p><ol><li>The first one is the updated value of the state</li><li>The second one is the dispatcher function that updates the state</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S64RnP58gYv0sZTDn14wBQ.png" /></figure><p>Now we need to fetch the data from the remote API and update the launches state.<br>To do that, we need to use another React hook called useEffect.<br>This function accepts two parameters:</p><ol><li>A function, which tells the hook what actions it should do</li><li>The <em>dependencies</em>, an array of state variables that trigger the function whenever they change. <br>When the array is empty, it means that the function will get called only once. <br>If you don’t pass the array, the function will get called on every render.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sS8D22FylpULWfuR3k8D-w.png" /></figure><p>After getting the data, we should display it in our HTML.</p><p>JSX syntax might be a bit tricky at the beginning, but it’ll get easier once you get used to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dACphTDrUVXAhe6QdfGOBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*miZyRJaJjr00hco_3wMImw.png" /><figcaption>It works! 🎉</figcaption></figure><p>We can now make it prettier using some CSS and display the images that are included in the response, for example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kBQPlwt1SDOnPlI8uoGfA.png" /></figure><p>We can also modularise our app creating aRocketLaunchcomponent.<br>Let’s create a new file called “RocketLaunch.js”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SEPk7PlE05V4nF3w5Z44iA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UeSArB5WrTtCmHlxHPlo6Q.png" /></figure><p>To pass data between a component and its child components, we use props.</p><p>Props are represented by an object that get passed as a parameter inside a functional component. Those items are “reactive” by default, which means that if a property is a state, its update will trigger a re-render everywhere it gets used.</p><h3>That’s it!</h3><p>There are still many things to learn, but I hope this article has helped you to understand more about the basic concepts of React.</p><p>Good luck! 😄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bc9589ab166" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/understanding-react-%EF%B8%8F-3bc9589ab166">Understanding React</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep dive into WebComponents]]></title>
            <link>https://itnext.io/deep-dive-into-webcomponents-6b36a4049fbf?source=rss-fd796195ca5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b36a4049fbf</guid>
            <category><![CDATA[litelement]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[lit-html]]></category>
            <dc:creator><![CDATA[Matteo Lobello]]></dc:creator>
            <pubDate>Mon, 20 Jan 2020 09:53:15 GMT</pubDate>
            <atom:updated>2021-05-12T16:57:31.753Z</atom:updated>
            <content:encoded><![CDATA[<h3>The native way to make dynamic component-based web apps.</h3><h3>What are WebComponents and why should I use them?</h3><p>WebComponents give you the possibility to <strong>create new HTML tags</strong>.</p><p>They aren’t new. They in fact were firstly announced back in 2011 and got very popular with the launch of Polymer, in 2014. The main issue was about the browser support, but nowadays, they have been natively implemented on all modern browsers.</p><h3>Polymer Project on Twitter</h3><p>An effort 9 years in the making, but we&#39;ve finally made it. WebComponents are supported natively in every major browser</p><p>The idea behind WebComponents is part of the success of many modern web frameworks: making elements that could be used <strong>multiple times</strong>. Just get a look at <a href="https://www.webcomponents.org/">webcomponents.org</a> to see what I mean.</p><p>WebComponents can be considered as the <strong>native</strong> equivalent to React, Angular or Vue.js. This way, you don’t have to include a huge amount of lines of code to make your web app work. The code is already built in the browser and ready to use, without worrying about downloading and executing tons of JavaScript.</p><p>This is a size comparison between the most common web frameworks:</p><ol><li>Vanilla Custom Elements → ready to use</li><li>LitElement → ~5kb</li><li>Vue.js → ~30kb</li><li>React.js (with React DOM) → ~110kb</li><li>AngularJS → ~160kb</li><li>Angular → ~550kb</li></ol><h3>Our first web component!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*yhzInYmFHKSCTujnJ1AfJg.png" /><figcaption>index.html</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rbs6vm4zae4fQ38DRf_DuQ.png" /><figcaption>clock-element.js</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*kahilfdiTOGTmbbDFk-oWw.gif" /><figcaption>Output</figcaption></figure><h3>What is the Shadow DOM?</h3><p>Let’s talk about this line of code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*ewfnzS71TGJgjS20fy3Omg.png" /></figure><p>This is the reason why Custom Elements stay <strong>re-usable</strong> during the development of various web apps. You can consider the Shadow DOM as a <strong>sub-DOM</strong> that <strong>can’t be interfered</strong> by the root DOM.</p><p>For example, if we import a CSS file in our HTML file, the rules written in it won’t simply be considered by the Shadow DOM.</p><p>A real world example could be the social media buttons, like Twitter’s Tweet button or Facebook’s Like button. They must be independent and the styling of the page should not interfere with the styling of those elements.</p><p>The “mode” property can be set to “open” or “closed”.<br>When it’s set to open, the shadow root can be accessed by the “<strong>shadowRoot</strong>” property of the HTMLElement. Otherwise, if it’s set to “closed”, the “shadowRoot” property will be <strong>null</strong>. Note that it’s <strong>easy to circumvent</strong> that, as you’ll still be able to access to the shadow root using the “_root” property of the HTMLElement.</p><h3>Making our code easier to write and more optimized</h3><p>Making Custom Elements optimized can be hard. That’s where <strong>LitElement</strong> kicks in.</p><p>LitElement is part of the Polymer family and makes Custom Elements development <strong>easier</strong> with a set of handy <strong>features </strong>that will help us to write <strong>cleaner code</strong> and <strong>optimize performance</strong>.</p><h3>Our first web component… with LitElement! 🔥</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VzfZS5sHL7hEnPSjP42-vw.png" /><figcaption>index.html</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zDcn6z-EymAHIj2lKccsJg.png" /><figcaption>clock-lit-element.js</figcaption></figure><h3>What is ‘&lt;script type=”module” …&gt;’?</h3><p>It’s the way we tell the browser we’re using <strong>ES Modules</strong>.<br>In practice, when a JS file imports some other file (such as a library, a style sheet, an image, or whatever else…), it must be imported with the <strong>type=”module”</strong> attribute. In our case, we needed it to import LitElement directly from our clock-lit-element.js file.</p><h3>The “properties” method</h3><p>This method allows us to <strong>declare</strong> the properties of our element. All of them must have the a “<strong>type</strong>” property, that can be “String”, “Array”, “Object”, etc…Properties can be declared as <strong>attributes</strong>. They will be automatically converted to object properties. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*Lu31iTDFAuJ-w-eqYMWXBQ.png" /></figure><p>Will automatically set the “name” property to “Steve”.</p><p>Every time one of the properties changes, it will call the render method and will <strong>update</strong> the content efficiently, updating only what is needed, not the whole component.</p><h3>The “styles” method</h3><p>The “styles” method gives us a cleaner way to <strong>declare</strong> the <strong>CSS</strong> of our component.</p><p>The function can also return an <strong>Array</strong>, which is useful when we want to share CSS code with multiple elements.</p><p>For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4FbHBMrZm9Wf0wackewcPA.png" /><figcaption>base-style.js</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-3y_lOUv2F_bqFwYEIG6ug.png" /><figcaption>my-element.js</figcaption></figure><h3>The “render” method</h3><p>This method generates the <strong>HTML structure</strong> of our Element.</p><p>It must return a value generated with the “<strong>html</strong>” function. To describe how it works, we must introduce the “<strong>string literals</strong>”, a new feature which is part of the ES6 features set. They are simple strings that must be declared with the <a href="https://superuser.com/questions/254076/how-do-i-type-the-tick-and-backtick-characters-on-windows"><strong>backtick</strong> character</a>.</p><p>Those kind of strings are great when you need to <strong>concatenate</strong> multiple strings.<br>For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*OMykoEWQdysCpnMfJxEw_Q.png" /></figure><p>When a function is called without the parenthesis and with a string literal (like html`&lt;h1&gt;Test&lt;/h1&gt;`), JavaScript passes the function <strong>two parameters,</strong> the <strong>static</strong> strings and the <strong>dynamic</strong> generated values.</p><p>LitHtml is able to generate <strong>optimized HTML</strong>, updating only things that needs to be updated.</p><h3>Communication between Elements</h3><p>To make Elements communicate, we have <strong>two</strong> options:</p><ul><li>Use the element instance and call its <strong>methods.<br></strong>This option is only available when making operations on <strong>child</strong> elements.<br>Example:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bMLaeJWLQE8m5HZvpAwnkA.png" /></figure><ul><li>Dispatch a <strong>global event.<br></strong>Example:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tg3zbkPhls3lClgJ1sz5Rw.png" /><figcaption>Dispatch an event</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*YW3PpTqLoI-fltOWtSO_2Q.png" /><figcaption>Do something on event</figcaption></figure><h3>Thanks for your attention!</h3><p><a href="https://gist.github.com/lobellomatteo/248755ac13f7332b5998bffc4e4598da">Here</a>’s the public Gist link if you want to get a look. 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b36a4049fbf" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/deep-dive-into-webcomponents-6b36a4049fbf">Deep dive into WebComponents</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Auth with NodeJS, Express, Mongoose and JWT]]></title>
            <link>https://itnext.io/auth-with-nodejs-express-mongoose-and-jwt-577aa3f2f707?source=rss-fd796195ca5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/577aa3f2f707</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Matteo Lobello]]></dc:creator>
            <pubDate>Tue, 24 Sep 2019 18:41:52 GMT</pubDate>
            <atom:updated>2021-05-12T16:58:52.429Z</atom:updated>
            <content:encoded><![CDATA[<p>Security of your database is one of the most important factor to consider when building a new project.</p><p>There are several ways to implement a solid <strong>authentication</strong> system. <br>In this article I’ll show you how to make one using JWT, completely from scratch and without the need to use third party services.</p><h3>What technologies are we going to use?</h3><ul><li><strong>NodeJS</strong>: a tool to server-side execute JavaScript code.</li><li><strong>Express</strong>: a micro-framework to make server development faster.</li><li><strong>Mongoose</strong>: a library that helps us connect to our MongoDB instance.</li><li><strong>JWT</strong> (JSON Web Token): an encrypted string that gets generated by the server and is stored by the client. On every request, that string will be sent by the client and will be verified by the server.</li><li><strong>Bcrypt</strong>: a library we will use to <a href="https://www.quora.com/What-is-a-hashed-password">hash</a> our passwords.</li><li><strong>BodyParser</strong>: will help us to retrieve body parameters when handling a request.</li></ul><h3>Setup our environment</h3><p>First of all, be sure to have NodeJS installed. If you haven’t, check out <a href="https://nodejs.dev/how-to-install-nodejs">this link</a>. Then, create a new MongoDB instance. You can create one <a href="https://cloud.mongodb.com/">here</a>, for free.<br>Finally, install NPM packages in our project folder via command line.</p><pre>npm install express jsonwebtoken body-parser bcryptjs</pre><h3>Ready to code!</h3><p>Now, we need to create our server scripts:</p><ul><li><strong>app.js</strong>, in which we’ll handle all our server requests.</li><li><strong>db.js</strong>, which will contain our Database models.</li></ul><p>Let’s create a very simple <strong>Express</strong> application: it will be the basic structure of our app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*5bKgTvhOBEZLpfMZtbRigw.png" /></figure><p>The “SECRET_JWT_CODE” is the encryption key we are going to use when generating our tokens.</p><p>Before proceeding implementing our endpoints, we should get a look at the <strong>db.js</strong> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kSSIZPURiS4yNuIPjQ9LYg.png" /><figcaption><strong>db.js</strong></figcaption></figure><p>This file essentially creates our DB model schemas. This means that each user related data is going to be saved under a document (collection) called “users” and will have two attributes, “email” and “password”. Of course, you can create as many <em>models</em> as you want, with as many <em>attributes</em> as you want.</p><p>Now we need to implement our <strong>routing</strong> system. The app will essentially have two endpoints, the first one for the <strong>sign up</strong> and the second one for the <strong>login</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sDzQtoNGIMCMHEo2flKVaw.png" /><figcaption><strong>app.js — sign up</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y9QzSOO1WQRcieTg4Y1xPg.png" /><figcaption><strong>app.js — login</strong></figcaption></figure><h3>It works!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*TLjkykt-bTAFO3Y3gOyzSw.png" /><figcaption>Screenshot of the data saved on our DB after having made a call to our /user/signup endpoint</figcaption></figure><h3>Final steps</h3><p>We successfully implemented our authentication system. Now, the client should <strong>save</strong> the token after the login and <strong>send it back</strong> every time it makes a new request.</p><p>Remember that Json Web Tokens have an <strong>expiration</strong> time. There are many ways to stay the user logged in. For example, whenever it happens, the <strong>client</strong> could <strong>refresh</strong> the token making a new login call.</p><p>On the <strong>backend side</strong>, this is how you could check if the token is <strong>valid</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P9MPFmKIULTPRsk3zNahHg.png" /><figcaption><strong>app.js</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*rJTj7rP0x1iZqwyYQiczNw.png" /><figcaption><strong>app.js</strong></figcaption></figure><p>You can find the Github gist <a href="https://gist.github.com/lobellomatteo/8bd2840160c55b7739ef88af7389cbe6">here</a>!😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=577aa3f2f707" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/auth-with-nodejs-express-mongoose-and-jwt-577aa3f2f707">Auth with NodeJS, Express, Mongoose and JWT</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduzione allo sviluppo Android]]></title>
            <link>https://matteolobello.medium.com/introduzione-allo-sviluppo-android-ad6753a1651f?source=rss-fd796195ca5e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad6753a1651f</guid>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Matteo Lobello]]></dc:creator>
            <pubDate>Sun, 22 Sep 2019 19:13:27 GMT</pubDate>
            <atom:updated>2020-09-15T22:15:36.399Z</atom:updated>
            <content:encoded><![CDATA[<p>Lo sviluppo di una applicazione Android può essere effettuato in svariati modi. Lo sviluppatore ha infatti la possibilità di decidere se creare:</p><ul><li><strong>una app nativa</strong></li><li><strong>una app ibrida</strong></li><li><strong>una webapp</strong></li></ul><p><strong>App native</strong></p><p>Le applicazioni native sono generalmente le più performanti e le più ottimizzate per il sistema operativo in uso. Sono le app che andremo a sviluppare durante questa “guida”.</p><p><strong>App ibride</strong></p><p>Le applicazioni ibride sono applicazioni che possono essere eseguite su più sistemi operativi, rinunciando in parte alle performance ottimali delle app native. I framework più utilizzati sono per esempio:</p><ul><li><strong>Apache Cordova</strong> (di Adobe), che permette di utilizzare HTML, CSS e Javascript</li><li><strong>React Native</strong> (di Facebook), che utilizza JSX, una versione “modificata” di JavaScript</li><li><strong>Flutter</strong> (di Google), il framework “più giovane”, che utilizza il linguaggio Dart e un “Flutter engine” che è in grado di aumentare notevolmente le performance</li></ul><p><strong>Webapp</strong></p><p>Sono le app che si basano interamente sulle piattaforme web.</p><p><strong>Strumenti di sviluppo</strong></p><p>Fino al 2014, le applicazioni Android venivano sviluppate utilizzando il programma “Eclipse”, oggi invece esiste un IDE chiamato “Android Studio” che è direttamente sviluppato da Google. È possibile scaricarlo dal <a href="https://developer.android.com/studio/">sito ufficiale</a> ed include anche l’ultima versione dell’SDK di Android.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HcM4keyL6okXftu7rRlkRQ.png" /></figure><p>Per creare un nuovo progetto sarà necessario cliccare su “Start a new Android Studio project”. Successivamente si aprirà questa schermata, selezionare “Empty Activity” e successivamente cliccare su “Next”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zEl18PRZKpyuJC2CktU-EQ.png" /></figure><p>Successivamente si aprirà una schermata nella quale andremo ad inserire i dati fondamentali dell’app, ovvero:</p><ul><li><strong>Name</strong>, il nome dell’app</li><li><strong>Package name</strong>, considerato come una sorta di ID, deve essere univoco affinché ché non ci siano errori durante la fase di pubblicazione dell’app (es. non può essere “com.instagram.android” in quanto già usato da Instagram)</li><li><strong>Save location</strong>, dove sarà salvato il codice sorgente dell’app</li><li><strong>Language</strong>, il linguaggio di programmazione che andremo ad utilizzare (Kotlin o Java)</li><li><strong>Minimum API level</strong>, la versione minima di Android che andremo a supportare (API 21 = Android 5.0, API 28 = Android 9.0, …)</li><li><strong>This project will support instant apps</strong>, una funzione che permette alle app di essere utilizzate senza scaricarle dal Play Store (come fossero “in streaming”)</li><li><strong>Use AndroidX artifacts</strong>, implementa la libreria AndroidX sviluppata da Google che ci aiuterà durante lo sviluppo dell’app</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m50p5OMC9nS6wFxHMnev3A.png" /></figure><p>Infine apparirà la schermata contenente il progetto che abbiamo appena configurato.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3FKDExYrwGMyBPc9bmmucA.png" /></figure><p><strong>Configurazione del telefono Android</strong></p><p>Per abilitare il telefono alla comunicazione con Android Studio, bisogna abilitare una impostazione chiamata “Debug USB”:</p><ul><li>Andare nelle impostazioni</li><li>Informazioni dispositivo</li><li>Cliccare su numero build per più volte fino a quando non comparirà il messaggio “ora sei uno sviluppatore”</li></ul><p><strong>Struttura di una app Android</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*KMkjKYgAKaFTa-ynMu-Ldg.png" /></figure><p>Le applicazioni Android si dividono principalmente in tre parti:</p><ul><li><strong>Codice Java</strong> (rosso), necessario per la creazione della logica dell’app</li><li><strong>Risorse</strong> (azzurro), come per esempio stringhe, traduzioni, immagini, colori e soprattutto layout</li><li><strong>Android Manifest</strong> (giallo), un file in formato XML che specifica informazioni importanti riguardanti l’app, come per esempio i permessi (accesso alla fotocamera, lettura del disco, accesso al microfono, accesso alla connessione internet, …), il nome dell’app, l’icona da usare, la lista delle “schermate” dell’app, …</li></ul><p><strong>Le Activity</strong></p><p>Le Activity sono entità che rappresentano le schermate di una app. Nella pratica sono classi Java che estendono la classe “Activity”; ogni Activity per essere eseguita deve essere registrata nell’AndroidManifest.xml (rosso).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xVJPiU4OtWizQc4Vl1WmWw.png" /></figure><p>In questo caso è importante notare come vengano inseriti altri tag che rendono la “MainActivity” la schermata che verrà aperta al lancio dell’app.</p><p><strong>Il ciclo di vita di un’Activity</strong></p><p>Le Activity posseggono uno speciale ciclo di vita che può essere rappresentato con il seguente schema:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*ExLj2pK-VsR4kXJ6ErZktg.png" /></figure><p>Nella pratica, il controllo del lifecycle di una Activity è effettuato attraverso l’override (ovvero la riscrittura) delle varie funzioni “onCreate”, “onPause”, “onResume”, etc…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*ODKvYoSa2deg-O6kWJvazw.png" /></figure><p><strong>Le View ed i Layout</strong></p><p>Lo sviluppo della parte grafica di una app Android viene effettuata con il linguaggio XML. Tutti i file di layout vengono inseriti nella cartella “res &gt; layout”. Una View / Layout rappresenta una singola componente dell’Activity. Mentre un layout è in grado di possedere più View “figlie”, una View non può avere elementi al suo interno.</p><p>Esempi di View:</p><ul><li>Button</li><li>TextView</li><li>ImageView</li></ul><p>Esempi di layout:</p><ul><li>LinearLayout</li><li>RelativeLayout</li><li>FrameLayout</li></ul><p><strong>La nostra prima app</strong></p><p>In questa app andremo a creare una semplice app che visualizza un testo a nostra scelta. Come precedentemente detto, esistono vari tipi di Layout. Il layout che utilizzeremo è il LinearLayout, un layout in grado di predisporre le proprie View figlie in modo orizzontale (default) o verticale. All’interno di questo LinearLayout inseriamo una TextView, ovvero un testo che comparirà nella nostra Activity. È importante notare come ogni View / Layout possegga gli attributi “layout_width” e “layout_height”, cioè larghezza e altezza. Il valore di questi attributi può essere di tre tipi:</p><ul><li>wrap_content, il “minimo” possibile</li><li>match_parent, il “massimo” possibile</li><li>dimensione fissa, come per esempio 30dp, 400dp, … I “dp”, ovvero Density-independent Pixels, sono “unità di misura” (come px, cioè pixel o “in”, cioè pollici), che Android è in grado di “scalare” in base alla dimensione dello schermo. Generalmente, i “dp” sono le unità più usate.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WW5IYG2o_TO0J10j_Gi4g.png" /></figure><p>Per eseguire l’app basta cliccare sul tasto “play” in alto a destra e selezionare il dispositivo collegato.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XCf9ZS6T4A3i0kEh00OEJg.png" /></figure><p>Cliccando su “OK”, l’applicazione verrà automaticamente lanciata sul dispositivo.</p><p><strong>Button</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*y2AdJ9pz1q0N4UvjgCx2Hg.jpeg" /></figure><p>In questo piccolo progetto andremo a sviluppare un’app che mostra un messaggio Toast al click di un bottone. Procediamo con lo sviluppo della UI aprendo il file activity_main.xml nella cartella “res &gt; layout” e inseriamo il seguente codice:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rPfC5LeujhVw5eBH7xqtZA.png" /></figure><p>In questo modo andremo a creare un semplice bottone. Un attributo importantissimo è l’Android ID, ovvero un identificativo di quella View all’interno di quel layout. L’ID è di fondamentale importanza in quanto permette di collegare il layout XML al file Java dell’Activity. Ora passiamo alla parte logica, aprendo il file MainActivity.java nella cartella “java”. Per prima cosa, dichiariamo una variabile di tipo Button. Per importare nella MainActivity la classe Button, sarà sufficiente scrivere “Button cliccamiBottone” per poi attendere che compaia un popup di colore azzurro e premere contemporaneamente sulla tastiera “ALT + Invio”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bqiz-iMZ3lE0YWw8jtnY3Q.png" /></figure><p>La funzione “findViewById” permette di assegnare alla variabile “cliccamiBottone” il bottone creato nel file XML. Essa richiede come parametro l’ID della View (il bottone nel nostro caso). Per ottenere gli ID delle View dalle classi Java, è necessario utilizzare la classe “R”. Quindi il parametro completo del findViewById sarà R.id.cliccami_bottone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K8JxlltaY0MUMJo0Q4ZaDw.png" /></figure><p>Per eseguire delle azioni al click del bottone, esiste il metodo “setOnClickListener”, che richiede come parametro una implementazione dell’interfaccia “OnClickListener”; Ciò che andremo a far fare al bottone una volta cliccato, deve essere inserito nella funzione “onClick”. Per far comparire un messaggio Toast, basta chiamare la funzione statica “makeText” presente nella classe Toast. Questa funzione richiede tre parametri: l’istanza dell’Activity, la stringa che rappresenterà il messaggio ed infine quanto tempo il Toast sarà visibile (Toast.LENGTH_SHORT, Toast.LENGTH_LONG).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GBpotdSAF7KMXuxoP4ULLQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad6753a1651f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>