<?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: Yasser Ameur el idrissi</title>
    <description>The latest articles on DEV Community by Yasser Ameur el idrissi (@getspooky).</description>
    <link>https://dev.to/getspooky</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%2F170565%2Faad4e68a-e224-4d9d-b87e-435a9dcf1ea0.jpeg</url>
      <title>DEV Community: Yasser Ameur el idrissi</title>
      <link>https://dev.to/getspooky</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/getspooky"/>
    <language>en</language>
    <item>
      <title>⚡A powerful HTTP router and URL matcher for building Deno web servers with dragon 🐲.
</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Thu, 14 Jan 2021 20:42:59 +0000</pubDate>
      <link>https://dev.to/getspooky/a-powerful-http-router-and-url-matcher-for-building-deno-web-servers-with-dragon-5fh9</link>
      <guid>https://dev.to/getspooky/a-powerful-http-router-and-url-matcher-for-building-deno-web-servers-with-dragon-5fh9</guid>
      <description>&lt;p&gt;Dragon is a simple, fast and low HTTP router and URL matcher for building Deno servers. If you need performance and good productivity, you will love it.&lt;/p&gt;

&lt;p&gt;Dragon is exchangeable with other web application frameworks for the backend the same way as React.js is exchangeable with Vue.js and Angular.js when it comes to frontend applications.&lt;/p&gt;

&lt;p&gt;That being said, let’s now move further with this article and find out the various features of this framework. Below I have picked out a few of the most important features of Dragon:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lightweight and modular design allows for a flexible framework. &lt;/li&gt;
&lt;li&gt;Focus on high performance.&lt;/li&gt;
&lt;li&gt;Middleware support, incoming HTTP request can be handled by a chain of middlewares and the final action.&lt;/li&gt;
&lt;li&gt;It helps in simplifying the configuration and customization steps for the application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These were a few of the major advantages of using Dragon in web application development. Let's start by using Dragon in your Deno application. &lt;/p&gt;

&lt;p&gt;First things first let's install Deno. I am on a Ubuntu OS  so I am using Shell. Simply open your terminal and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://deno.land/x/install/install.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next step is specifying Deno’s path to bash.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano ~/.bashrc
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;DENO_INSTALL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/home/&lt;/span&gt;&lt;span class="nv"&gt;$USER&lt;/span&gt;&lt;span class="s2"&gt;/.deno"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$DENO_INSTALL&lt;/span&gt;&lt;span class="s2"&gt;/bin:&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you have it installed, close the terminal, open a new one, and type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;deno &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It should output something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;deno 1.6.3 &lt;span class="o"&gt;(&lt;/span&gt;release, x86_64-unknown-linux-gnu&lt;span class="o"&gt;)&lt;/span&gt;
v8 8.8.294
typescript 4.1.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💬 If you are using a different operating system, just head over to &lt;a href="https://deno.land/#installation"&gt;deno.land installation&lt;/a&gt;. They have a lot of ways you can easily install it on your machine.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Awesome! &lt;/p&gt;

&lt;p&gt;Let's move ahead&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a new folder and call it &lt;strong&gt;dragon_demo&lt;/strong&gt; (but you can call it anything you want)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once you create a folder simply &lt;code&gt;cd&lt;/code&gt; into your new project. Create a file called &lt;code&gt;server.ts&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In your &lt;code&gt;src/server.ts&lt;/code&gt; TypeScript file, use the following code to import Dragon, to create an instance of an Dragon application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RequestMethod&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://deno.land/x/dragon@v1.1.0/lib/mod.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listenAndServe&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;🐉 Serveur listining&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's run this file. Open your terminal and in your project root folder type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;deno run &lt;span class="nt"&gt;--allow-net&lt;/span&gt; server.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💬 Deno is secure by default. Therefore, unless you specifically enable it, a deno module has no file, network, or environment access for example.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You should get something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;🐉 Serveur listining
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run deno run &lt;code&gt;---allow-net &amp;lt;file_name&amp;gt;&lt;/code&gt; in your terminal, Deno will look at all your imports and install them locally in your machine if they are not there.&lt;/p&gt;

&lt;p&gt;The first time you run this it will go to this URL &lt;code&gt;https://deno.land/x/dragon@v1.1.0/lib/mod.ts&lt;/code&gt; and install the dragon package.&lt;/p&gt;

&lt;p&gt;In the next line we do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a new instance of our application with various options, and it will be the basis of everything as you progress further in this tutorial.&lt;/p&gt;

&lt;p&gt;An instance of application has some optional properties as well:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;hostname&lt;/code&gt;: A unique name for a computer or network node in a network. This defaults to &lt;code&gt;0.0.0.0&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;port&lt;/code&gt;: Numbers used by protocols for operation of network applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;certFile&lt;/code&gt;: A concatenation of all Certificate Authority (CA).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;🖇 Learn more about &lt;a href="https://github.com/xanny-projects/dragon#installation"&gt;application options&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then we write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listenAndServe&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the port number and tell Deno to listen to the port, which is 8080. &lt;/p&gt;

&lt;p&gt;Let's register two routes mapping URL path to handler.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💬 We believe development must be an enjoyable and creative experience to be truly fulfilling (&lt;code&gt;HttpRequest&lt;/code&gt;, &lt;code&gt;HttpResponse&lt;/code&gt;) as parameters.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;withMethods&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;RequestMethod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handleFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;withBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello Dragon&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We create a new router instance by doing &lt;code&gt;const r = app.routes();&lt;/code&gt; and then we create a new route called &lt;code&gt;hello&lt;/code&gt; which is of type &lt;code&gt;RequestMethod.GET&lt;/code&gt;. If an incoming request URL matches one of the paths, the corresponding handler is called passing. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💬 By default Dragon all methods for this route(s) like &lt;code&gt;PUT&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;, &lt;code&gt;PATCH&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And now we are done. ✅ Let's run this and see what we have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;deno run &lt;span class="nt"&gt;--allow-net&lt;/span&gt; server.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now open your favorite browser and go to &lt;code&gt;http://localhost:8080/hello&lt;/code&gt;. You will see something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Hello Dragon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Awesome&lt;/p&gt;

&lt;p&gt;Honestly the hardest part is done. Conceptually we are 50% there.&lt;/p&gt;

&lt;p&gt;Now we only have two things remaining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add a not found route so that when the user tries to access an unknown route.&lt;/li&gt;
&lt;li&gt;Add a logger middleware that consoles the response time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using the &lt;code&gt;notFoundHandler&lt;/code&gt; options you may define a route that will be executed when no other route matches the incoming request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fallback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="s2"&gt;`🤦 Page Not Found`&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;MiddlewareState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Cancel&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;notFoundHandler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;fallback&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;fallback is a &lt;code&gt;Middleware&lt;/code&gt; literally means anything you put in the middle of one layer of the software and another. As you can see fallback has access to the &lt;code&gt;HttpRequest&lt;/code&gt; and &lt;code&gt;HttpResponse&lt;/code&gt;. Middleware can either terminate the HTTP request or pass it on to another middleware function using &lt;code&gt;MiddlewareState.Next&lt;/code&gt; or &lt;code&gt;MiddlewareState.Cancel&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let's see if this works.&lt;/p&gt;

&lt;p&gt;Restart the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;deno run &lt;span class="nt"&gt;--allow-net&lt;/span&gt; server.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open up a new tab Set the request to &lt;code&gt;GET&lt;/code&gt; and in the &lt;code&gt;URL&lt;/code&gt; bar type &lt;code&gt;http://localhost:8080/something-unknown&lt;/code&gt;.&lt;br&gt;
You should get something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;🤦 Page Not Found
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Logging Response time in console, create a new file called &lt;code&gt;logger.ts&lt;/code&gt; and enter the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;MiddlewareState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://deno.land/x/dragon@v1.1.0/lib/mod.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Logger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Handle at: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;MiddlewareState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Next&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your &lt;code&gt;server.ts&lt;/code&gt; file add this code:&lt;/p&gt;

&lt;p&gt;Now let's import and register the middleware.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RequestMethod&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://deno.land/x/dragon@v1.1.0/lib/mod.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Logger&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./logger.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;maxRoutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;withMethods&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;RequestMethod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handleFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;withBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello Dragon&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listenAndServe&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;🐉 Serveur listining&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;I hope that you found this article useful and that it was able to help you learn something today.&lt;/p&gt;

&lt;p&gt;If you are interested in joining the dragon team to improve the framework, You are welcome.&lt;/p&gt;

&lt;p&gt;A Star 🌟 on our &lt;a href="https://github.com/xanny-projects/dragon"&gt;github repository&lt;/a&gt; could be a good and very feedback for us.&lt;/p&gt;

</description>
      <category>deno</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>A powerful HTTP router and URL matcher for building Deno web servers with dragon🐉.</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Fri, 08 Jan 2021 22:59:49 +0000</pubDate>
      <link>https://dev.to/getspooky/a-powerful-http-router-and-url-matcher-for-building-deno-web-servers-with-dragon-341k</link>
      <guid>https://dev.to/getspooky/a-powerful-http-router-and-url-matcher-for-building-deno-web-servers-with-dragon-341k</guid>
      <description>&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;I built a simple, fast and low HTTP router and URL matcher for building Deno servers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Category Submission:
&lt;/h3&gt;

&lt;p&gt;framework, middleware, http-matcher, deno, server&lt;/p&gt;

&lt;h3&gt;
  
  
  App Link
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/xanny-projects/dragon"&gt;https://github.com/xanny-projects/dragon&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Screenshots
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RequestMethod&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://deno.land/x/dragon@v1.0.6/lib/mod.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;maxRoutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;withMethods&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;RequestMethod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handleFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;withBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello Dragon&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/demo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;HandleFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;withBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello Dragon Demo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listenAndServe&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Description
&lt;/h3&gt;

&lt;p&gt;Dragon is a &lt;em&gt;simple&lt;/em&gt;, &lt;em&gt;fast&lt;/em&gt; and &lt;em&gt;low&lt;/em&gt; &lt;strong&gt;HTTP&lt;/strong&gt; router and &lt;strong&gt;URL&lt;/strong&gt; matcher for building &lt;strong&gt;Deno&lt;/strong&gt; servers. If you need performance and good productivity, you will love it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Developer friendly, very expressive and help the developer in their daily use, without sacrificing performance and security.&lt;/li&gt;
&lt;li&gt;Lightweight and modular design allows for a flexible framework.&lt;/li&gt;
&lt;li&gt;Focus on high performance.&lt;/li&gt;
&lt;li&gt;Middleware support, incoming HTTP request can be handled by a chain of middlewares and the final action.&lt;/li&gt;
&lt;li&gt;Excellent and fluent documentation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Link to Source Code
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/xanny-projects/dragon"&gt;https://github.com/xanny-projects/dragon&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Permissive License
&lt;/h3&gt;

&lt;p&gt;Apache-2.0 License&lt;/p&gt;

&lt;h3&gt;
  
  
  How I built it
&lt;/h3&gt;

&lt;p&gt;(How did you utilize DigitalOcean’s App Platform? Did you learn something new along the way? Pick up a new skill?)&lt;br&gt;
I have used DigitalOcean for the first time, I don't have much idea of other features that DigitalOcean provides but it was pretty easy to deploy the app and I really liked it.&lt;/p&gt;

</description>
      <category>dohackathon</category>
    </item>
    <item>
      <title>I built a Fast and low HTTP router and URL matcher for building Deno servers 🦕.</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Tue, 22 Dec 2020 09:20:14 +0000</pubDate>
      <link>https://dev.to/getspooky/i-built-a-fast-and-low-http-router-and-url-matcher-for-building-deno-servers-1i62</link>
      <guid>https://dev.to/getspooky/i-built-a-fast-and-low-http-router-and-url-matcher-for-building-deno-servers-1i62</guid>
      <description>&lt;p&gt;Xanny finally reached version 1.0 in Dec 2020. According to its &lt;a href="https://github.com/xanny-projects/xanny"&gt;official repository&lt;/a&gt;, Xanny is a simple, fast and low HTTP router and URL marcher for building Deno servers.&lt;br&gt;
You can assume xanny as a layer built on the top of the Deno that helps manage a server and routes. It provides a robust set of features to develop web and mobile applications.&lt;/p&gt;

&lt;p&gt;Let's see some of the core features of Xanny framework:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developer friendly, very expressive and help the developer in their daily use, without sacrificing performance and security.&lt;/li&gt;
&lt;li&gt;Lightweight and modular design allows for a flexible framework.&lt;/li&gt;
&lt;li&gt;Focus on high performance.&lt;/li&gt;
&lt;li&gt;Middleware support, incoming HTTP request can be handled by a chain of middlewares and the final action.&lt;/li&gt;
&lt;li&gt;Excellent and fluent documentation.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Install Xanny
&lt;/h2&gt;

&lt;p&gt;Assuming you’ve already installed Deno, create a directory and &lt;code&gt;.ts&lt;/code&gt; file to hold your code, and make that your working directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;xanny-app
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;xanny-app
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;xanny_example.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So to use version 1.0.0 of xanny, you would want to import&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//deno.land/x/xanny@v1.0.0/lib/mod.ts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's start registering a couple of URL paths and handlers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RequestMethod&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://deno.land/x/xanny@v1.0.0/lib/mod.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NewRoute&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;maxRoutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;WithMethods&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;RequestMethod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;HandleFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;WithBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello Xanny&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/demo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;HandleFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;WithBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello Xanny Demo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ListenAndServe&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we register two routes mapping URL path to handler. if an incoming request URL matches one of the paths, the corresponding handler is called passingWe believe development must be an enjoyable and creative experience to be truly fulfilling (&lt;code&gt;HttpRequest&lt;/code&gt;, &lt;code&gt;HttpResponse&lt;/code&gt;) as parameters.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As you can see Xanny provides a very simple and expressive method of defining routes and behavior without complicated routing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To see the results you need to start a web server on your development machine. You can do this by running the following command in the &lt;code&gt;xanny-app&lt;/code&gt; directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;deno&lt;/span&gt; &lt;span class="nx"&gt;run&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;allow&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;net&lt;/span&gt; &lt;span class="nx"&gt;xanny_example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see your application in action, open a browser window and navigate to &lt;a href="http://localhost:8080"&gt;http://localhost:8080&lt;/a&gt;. You should see the Xanny &lt;br&gt;
&lt;code&gt;Hello Xanny&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We encourage you to contribute to Xanny! Please check out the guidelines about how to proceed.&lt;/p&gt;

&lt;p&gt;Whether you’re helping us fix bugs, improve the docs, or spread the word, we’d love to have you as part of the Xanny community! 💪💜 See CONTRIBUTING.md for more information on what we’re looking for and how to get started.&lt;br&gt;
&lt;a href="https://github.com/xanny-projects/xanny"&gt;👉 Github Repository&lt;/a&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
    </item>
    <item>
      <title>THE BEGINNER’S GUIDE: Fast , low HTTP router and URL matcher for building Deno servers 🦕</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Mon, 21 Dec 2020 10:09:33 +0000</pubDate>
      <link>https://dev.to/getspooky/the-beginner-s-guide-fast-low-http-router-and-url-matcher-for-building-deno-servers-271</link>
      <guid>https://dev.to/getspooky/the-beginner-s-guide-fast-low-http-router-and-url-matcher-for-building-deno-servers-271</guid>
      <description>&lt;p&gt;Xanny finally reached version 1.0 in Dec 2020. According to its &lt;a href="https://github.com/xanny-projects/xanny"&gt;official repository&lt;/a&gt;, Xanny is a simple, fast and low HTTP router and URL marcher for building Deno servers.&lt;br&gt;
You can assume xanny as a layer built on the top of the Deno that helps manage a server and routes. It provides a robust set of features to develop web and mobile applications.&lt;/p&gt;

&lt;p&gt;Let's see some of the core features of Xanny framework:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developer friendly, very expressive and help the developer in their daily use, without sacrificing performance and security.&lt;/li&gt;
&lt;li&gt;Lightweight and modular design allows for a flexible framework.&lt;/li&gt;
&lt;li&gt;Focus on high performance.&lt;/li&gt;
&lt;li&gt;Middleware support, incoming HTTP request can be handled by a chain of middlewares and the final action.&lt;/li&gt;
&lt;li&gt;Excellent and fluent documentation.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Install Xanny
&lt;/h2&gt;

&lt;p&gt;Assuming you’ve already installed Deno, create a directory and &lt;code&gt;.ts&lt;/code&gt; file to hold your code, and make that your working directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;xanny-app
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;xanny-app
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;xanny_example.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So to use version 1.0.0 of xanny, you would want to import&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//deno.land/x/xanny@v1.0.0/lib/mod.ts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's start registering a couple of URL paths and handlers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RequestMethod&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://deno.land/x/xanny@v1.0.0/lib/mod.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NewRoute&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;maxRoutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;WithMethods&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;RequestMethod&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;HandleFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;WithBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello Xanny&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/demo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;HandleFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;ResponseWriter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;WithBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello Xanny Demo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;Return&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ListenAndServe&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we register two routes mapping URL path to handler. if an incoming request URL matches one of the paths, the corresponding handler is called passingWe believe development must be an enjoyable and creative experience to be truly fulfilling (&lt;code&gt;HttpRequest&lt;/code&gt;, &lt;code&gt;HttpResponse&lt;/code&gt;) as parameters.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As you can see Xanny provides a very simple and expressive method of defining routes and behavior without complicated routing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To see the results you need to start a web server on your development machine. You can do this by running the following command in the &lt;code&gt;xanny-app&lt;/code&gt; directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;deno&lt;/span&gt; &lt;span class="nx"&gt;run&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;allow&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;net&lt;/span&gt; &lt;span class="nx"&gt;xanny_example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see your application in action, open a browser window and navigate to &lt;a href="http://localhost:8080"&gt;http://localhost:8080&lt;/a&gt;. You should see the Xanny &lt;br&gt;
&lt;code&gt;Hello Xanny&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We encourage you to contribute to Xanny! Please check out the guidelines about how to proceed.&lt;/p&gt;

&lt;p&gt;Whether you’re helping us fix bugs, improve the docs, or spread the word, we’d love to have you as part of the Xanny community! 💪💜 See CONTRIBUTING.md for more information on what we’re looking for and how to get started.&lt;br&gt;
&lt;a href="https://github.com/xanny-projects/xanny"&gt;👉 Github Repository&lt;/a&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>deno</category>
      <category>showdev</category>
    </item>
    <item>
      <title>How to Validate Forms Data in React Using Reactrix</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Sun, 20 Sep 2020 22:09:05 +0000</pubDate>
      <link>https://dev.to/getspooky/how-to-validate-forms-data-in-react-using-reactrix-46f9</link>
      <guid>https://dev.to/getspooky/how-to-validate-forms-data-in-react-using-reactrix-46f9</guid>
      <description>&lt;p&gt;Hello! One of the most common tasks in software development is input validation. Any app has different forms that submit some data, and we want to check numerous conditions: that fields are not empty and that they have a proper format (like emails), length, and so on. Yes, we can do it manually, but this is not the best path. It is better to use a specific validation library. For React apps, the best choice is Reactrix. In this post, we will see how to install it to your Reat apps, how to use it, and observe the most important built-in validators.&lt;/p&gt;

&lt;p&gt;Thanks to React's reactivity model, it's really easy to roll your own form validations. This can be done with a simple method call on the form submit.&lt;br&gt;
Thankfully, there are great validation library for React. In this article, we'll be looking at how Reactrix can be used to simplify:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Validation&lt;/li&gt;
&lt;li&gt;Multi-step form validation&lt;/li&gt;
&lt;li&gt;Child component validation&lt;/li&gt;
&lt;li&gt;Error messages&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will be using create-react-app for making a React application. Let’s just create a new React app using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; create-react-app
&lt;span class="nv"&gt;$ &lt;/span&gt;create-react-app form-validation-react
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the app&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; create-react-app
&lt;span class="nv"&gt;$ &lt;/span&gt;create-react-app form-validation-react
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open our newly created app on &lt;code&gt;http://localhost:3000/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let have a simple example. You’re building a signup form. You want to check that user provides a correct input, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Email has a valid format.&lt;/li&gt;
&lt;li&gt;All fields are filled.&lt;/li&gt;
&lt;li&gt;etc&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can do this manually, but it is not the best route to follow. First, is that you will find yourself in a forest of nested if-else constructs, that you most probably could not understand after a week or two. Next, even small additions will bring a lot of changes. This is always safer to rely on an external validation library. For React applications, there are several choices, but in this article we use Reactrix.&lt;/p&gt;

&lt;p&gt;You can install Reactrix using your package manager CLI :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;reactrix &lt;span class="nt"&gt;--save&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, you need to import Reactrix in your src/Login.js components. So Let's define some validations in React components&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useValidate&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;reactrix&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;({});&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setValidator&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useValidate&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleSubmit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;setValidator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;required|email&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;required|string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt; 

  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;  
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;container&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;   
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;Email&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&amp;gt;  &lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Enter Email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt; &lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;Password&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&amp;gt;  &lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Enter Password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt; &lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleSubmit&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Login&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&amp;gt;    &lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;          &lt;span class="nx"&gt;Forgot&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&amp;gt;  &lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reactrix has built-in localization support for validation messages. The default language for Reactrix is en in order to set the locale you pass the locale key/code to the localize method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [msg, setValidator] = useValidate('fr');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can learn more about Reactrix rules in the &lt;a href="https://github.com/getspooky/Reactrix"&gt;Reatrix Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👋 Happy Coding.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>validation</category>
    </item>
    <item>
      <title>Data Structures Easy to Advanced Using JavaScript -Ep1</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Thu, 17 Sep 2020 09:57:26 +0000</pubDate>
      <link>https://dev.to/getspooky/data-structures-easy-to-advanced-using-javascript-ep1-b1a</link>
      <guid>https://dev.to/getspooky/data-structures-easy-to-advanced-using-javascript-ep1-b1a</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This is a series of tutorials. We are going to:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Dive into data structures.&lt;/li&gt;
&lt;li&gt;Compare between data structures.&lt;/li&gt;
&lt;li&gt;Look at language support for different data structures.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Data Structures
&lt;/h2&gt;

&lt;p&gt;Data Structures (DS) tutorial provides basic and advanced concepts of Data Structure. Our Data Structure tutorial is designed for beginners and professionals.&lt;/p&gt;

&lt;p&gt;Data Structure is a way to store and organize data so that it can be used efficiently.&lt;/p&gt;

&lt;p&gt;Our Data Structure tutorial includes all topics of Data Structure such as Array, Pointer, Structure, Linked List, Stack, Queue, Graph, Searching, Sorting, Programs, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Need of Data Structures
&lt;/h2&gt;

&lt;p&gt;As applications are getting complexed and amount of data is increasing day by day, there may arrise the following problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Processor speed&lt;/strong&gt;: To handle very large amout of data, high speed processing is required, but as the data is growing day by day to the billions of files per entity, processor may fail to deal with that much amount of data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Search&lt;/strong&gt;: Consider an inventory size of 106 items in a store, If our application needs to search for a particular item, it needs to traverse 106 items every time, results in slowing down the search process. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiple requests&lt;/strong&gt;: If thousands of users are searching the data simultaneously on a web server, then there are the chances that a very large server can be failed during that process.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;in order to solve the above problems, data structures are used. Data is organized to form a data structure in such a way that all items are not required to be searched and required data can be searched instantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages of Data Structures
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Reusability&lt;/strong&gt; : Data structures are reusable, i.e. once we have implemented a particular data structure, we can use it at any other place. Implementation of data structures can be compiled into libraries which can be used by different clients.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Abstraction&lt;/strong&gt;: The client program uses the data structure through interface only, without getting into the implementation details.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Efficiency&lt;/strong&gt;: Efficiency of a program depends upon the choice of data structures. For example: suppose, we have some data and we need to perform the search for a perticular record. In that case, if we organize our data in an array, we will have to search sequentially element by element. hence, using array may not be very efficient here. There are better data structures which can make the search process efficient like ordered array, binary search tree or hash tables.&lt;/p&gt;

&lt;p&gt;In the next episode you will how to code various data structures together with simple to follow step-by-step instructions. Every data structure presented will be accompanied by some working source code (in JavaScript) to solidify your understanding.&lt;/p&gt;

&lt;p&gt;⭐️ Course Contents ⭐️&lt;br&gt;
⌨️ Abstract data types&lt;br&gt;
⌨️ Introduction to Big-O&lt;br&gt;
⌨️ Dynamic and Static Arrays&lt;br&gt;
⌨️ Dynamic Array Code&lt;br&gt;
⌨️ Linked Lists Introduction&lt;br&gt;
⌨️ Doubly Linked List Code&lt;br&gt;
⌨️ Stack Introduction&lt;br&gt;
⌨️ Stack Implementation&lt;br&gt;
⌨️ Stack Code&lt;br&gt;
⌨️ Queue Introduction&lt;br&gt;
⌨️ Queue Implementation&lt;br&gt;
⌨️ Queue Code&lt;br&gt;
⌨️ Priority Queue Introduction&lt;br&gt;
⌨️ Priority Queue Min Heaps and Max Heaps&lt;br&gt;
⌨️ Priority Queue Inserting Elements&lt;br&gt;
⌨️ Priority Queue Removing Elements&lt;br&gt;
⌨️ Priority Queue Code&lt;br&gt;
⌨️ Union Find Introduction&lt;br&gt;
⌨️ Union Find Kruskal's Algorithm&lt;br&gt;
⌨️ Union Find - Union and Find Operations&lt;br&gt;
⌨️ Union Find Path Compression&lt;br&gt;
⌨️ Union Find Code&lt;br&gt;
⌨️ Binary Search Tree Introduction&lt;br&gt;
⌨️ Binary Search Tree Insertion&lt;br&gt;
⌨️ Binary Search Tree Removal&lt;br&gt;
⌨️ Binary Search Tree Traversals&lt;br&gt;
⌨️ Binary Search Tree Code&lt;br&gt;
⌨️ Hash table hash function&lt;br&gt;
⌨️ Hash table separate chaining&lt;br&gt;
⌨️ Hash table separate chaining source code&lt;br&gt;
⌨️ Hash table open addressing&lt;br&gt;
⌨️ Hash table linear probing&lt;br&gt;
⌨️ Hash table quadratic probing&lt;br&gt;
⌨️ Hash table double hashing&lt;br&gt;
⌨️ Hash table open addressing removing&lt;br&gt;
⌨️ Hash table open addressing code&lt;br&gt;
⌨️ Fenwick Tree range queries&lt;br&gt;
⌨️ Fenwick Tree point updates&lt;br&gt;
⌨️ Fenwick Tree construction&lt;br&gt;
⌨️ Fenwick tree source code&lt;br&gt;
⌨️ Suffix Array introduction&lt;br&gt;
⌨️ Longest Common Prefix (LCP) array&lt;br&gt;
⌨️ Suffix array finding unique substrings&lt;br&gt;
⌨️ Longest common substring problem suffix array&lt;br&gt;
⌨️ Longest common substring problem suffix array &lt;/p&gt;

&lt;h2&gt;
  
  
  part 2
&lt;/h2&gt;

&lt;p&gt;⌨️ Longest Repeated Substring suffix array&lt;br&gt;
⌨️ Balanced binary search tree rotations&lt;br&gt;
⌨️ AVL tree insertion&lt;br&gt;
⌨️ AVL tree removals&lt;br&gt;
⌨️ AVL tree source code&lt;br&gt;
⌨️ Indexed Priority Queue | Data Structure&lt;br&gt;
⌨️ Indexed Priority Queue | Data Structure | Source Code&lt;/p&gt;

&lt;p&gt;Feel free to follow me on &lt;a href="https://github.com/getspooky/"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Why Should We Use Aspect-Oriented Programming ?</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Thu, 13 Aug 2020 16:07:24 +0000</pubDate>
      <link>https://dev.to/getspooky/why-should-we-use-aspect-oriented-programming-3dke</link>
      <guid>https://dev.to/getspooky/why-should-we-use-aspect-oriented-programming-3dke</guid>
      <description>&lt;p&gt;In computing, aspect-oriented programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It does so by adding additional behavior to existing code (an advice) without modifying the code itself, instead separately specifying which code is modified via a &lt;code&gt;pointcut&lt;/code&gt; specification, such as "log all function calls when the function's name begins with &lt;code&gt;set&lt;/code&gt;. This allows behaviors that are not central to the business logic (such as logging) to be added to a program without cluttering the code, core to the functionality. AOP forms a basis for aspect-oriented software development.&lt;/p&gt;

&lt;p&gt;Okay it might look scary when you read the definition. No worries I got you covered in this article. Let’s deep dive into the some of issues that you would face when writing the code in a method/function.&lt;/p&gt;

&lt;p&gt;Let’s look at the following example pseudo-code :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;notify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;toPerson&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;toPerson&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isBlockList&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;UserBlockedException&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;toPerson&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is simple method whose core functionality is send notifation message. But it lacks certain considerations so lets add logging for diagnostics to the above &lt;code&gt;notify&lt;/code&gt; method. The code might look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;notify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;toPerson&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Entered sendMessage &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;toPerson&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;toPerson&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isBlockList&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;toPerson&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; is blocked by recepient"`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;UserBlockedException&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;toPerson&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nx"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Exiting sendMessage&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You see that there are bits of code for logging that have become tangled with the core business functionality. These cross-cutting concerns are almost same for most of the methods. &lt;code&gt;Security&lt;/code&gt;, &lt;code&gt;logging&lt;/code&gt;, &lt;code&gt;API analytics&lt;/code&gt; (ex: to measure how much time each method took) etc are some of the examples for cross-cutting concerns.&lt;/p&gt;

&lt;p&gt;Voila!, AOP solves the issue by encapsulating the cross-cutting concerns in a modular element called &lt;strong&gt;aspect&lt;/strong&gt;. An Aspect is just like any other modular implementation (like a class) in Object-oriented programming(OOP).&lt;/p&gt;

&lt;p&gt;Common terminology in AOP :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;An Aspect&lt;/strong&gt; is module of code that encapsulates the cross-cutting concerns. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Join point&lt;/strong&gt; The point in the program that has to be subjected to an aspect. Join point can be &lt;code&gt;method level&lt;/code&gt;, &lt;code&gt;constructor level&lt;/code&gt;, &lt;code&gt;field level&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Advice&lt;/strong&gt; Specifies the action that should be executed on the join point and also specifies when should the action be executed, like should it be applied before entering the method, after returning from the method, after an exception from method , both before and after the method etc. An Aspect has group of advices.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Aspect-oriented Programming is an extension of Object-oriented Programming. AOP complements Object-oriented programming by increasing modularity. Now have a look at the textbook definition that I have mentioned earlier, I hope that it would not be scary instead be more meaningful. I would suggest you to practice and use AOP wherever possible. This is one of paths for being better programmer.&lt;/p&gt;

</description>
      <category>computerscience</category>
    </item>
    <item>
      <title>🍪 A highly scalable, professional boilerplate for building fast, robust and adaptable mern web apps 🚀</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Thu, 09 Jul 2020 09:55:30 +0000</pubDate>
      <link>https://dev.to/getspooky/a-highly-scalable-professional-boilerplate-for-building-fast-robust-and-adaptable-mern-web-apps-36hl</link>
      <guid>https://dev.to/getspooky/a-highly-scalable-professional-boilerplate-for-building-fast-robust-and-adaptable-mern-web-apps-36hl</guid>
      <description>&lt;p&gt;In programming, the term boilerplate code refers to blocks of code used over and over again&lt;/p&gt;

&lt;p&gt;Let’s assume your development stack consists of several libraries, such as React, Babel, Express, Jest, Webpack, etc. When you start a new project, you initialize all these libraries and configure them to work with each other.&lt;/p&gt;

&lt;p&gt;With every new project that you start, you will be repeating yourself. You could also introduce inconsistencies in how these libraries are set up in each project. This can cause confusion when you switch between projects.&lt;/p&gt;

&lt;p&gt;This is where boilerplates come in. A boilerplate is a template that you can clone and reuse for every project.&lt;/p&gt;

&lt;p&gt;CookieScript Boilerplate uses familiar tools and implements best practices around them to provide you a SOLID development experience. This project does not impose a specific development philosophy or framework, so you're free to architect your code in the way that you want.&lt;/p&gt;

&lt;p&gt;Here are some of the awesome CookieScript features you'll enjoy👋&lt;/p&gt;

&lt;p&gt;Quick scaffolding&lt;br&gt;
CookieScript offers a built-in tool for the command line is known as Geek which allows performing the majority of those tedious and repetitive programming tasks that many JavaScript developers avoid performing manually.&lt;/p&gt;

&lt;p&gt;Next generation JavaScript&lt;br&gt;
Use template strings, object destructuring, arrow functions, JSX syntax and more.&lt;/p&gt;

&lt;p&gt;No Lock-In&lt;br&gt;
Under the hood, we use webpack, Babel, ESLint, and other amazing projects to power your app.&lt;/p&gt;

&lt;p&gt;SEO friendly&lt;br&gt;
There are a few problems for search engine rankings when it comes to a vanilla &lt;code&gt;React app&lt;/code&gt;. We follow best practices to make your web app attractive to &lt;code&gt;Google&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Authentication&lt;br&gt;
Authentication is the most important factor in a web application, and developers need to spend a lot of time writing the authentication code. CookieScript contains an inbuilt authentication system, you only need to configure models, views, and controllers to make the application work.&lt;/p&gt;

&lt;p&gt;Whether you're helping us fix bugs, improve the docs, or spread the word, we'd love to have you as part of the community! 💜💪 See CONTRIBUTING.md for more information on what we're looking for and how to get started.&lt;/p&gt;

&lt;p&gt;GitHub : &lt;a href="https://github.com/getspooky/CookieScript"&gt;https://github.com/getspooky/CookieScript&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>🐹 Create, develop and manage your projects through an accompanying graphical user interface.🎉</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Sat, 30 May 2020 11:01:21 +0000</pubDate>
      <link>https://dev.to/getspooky/create-develop-and-manage-your-projects-through-an-accompanying-graphical-user-interface-2ihp</link>
      <guid>https://dev.to/getspooky/create-develop-and-manage-your-projects-through-an-accompanying-graphical-user-interface-2ihp</guid>
      <description>&lt;p&gt;This awesome tool allows developers to graphically create a new project, live monitor app performance, add templates to project, and more. This is a pretty big deal, as getting familiar with this tool can make spinning up and maintaining any type of application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages and use cases
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Manage your local projects&lt;/li&gt;
&lt;li&gt;Configure your application without messing up the config files&lt;/li&gt;
&lt;li&gt;Install templates&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;You can install it using the installers below :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Distributions available for Linux, macOS, Windows.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/Routine-App/Routine.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Move to the appropriate directory: cd &lt;code&gt;&amp;lt;YOUR_PROJECT_NAME&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Run npm run routine in order to start Routine project.&lt;/p&gt;

&lt;p&gt;Now you can go to localhost:8080 and see your app!&lt;/p&gt;

&lt;h2&gt;
  
  
  Supported Templates
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/electron-react-boilerplate/electron-react-boilerplate"&gt;electron-react-boilerplate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/sahat/hackathon-starter"&gt;hackathon-starter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/laravel/laravel"&gt;laravel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/react-boilerplate/react-boilerplate"&gt;react-boilerplate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/h5bp/server-configs-nginx"&gt;server-configs-nginx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Microsoft/TypeScript-Node-Starter"&gt;TypeScript-Node-Starter&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Routine has a few requirements you should be aware of before installing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://golang.org/"&gt;Golang&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nodejs.org/en/download/"&gt;Node.js &amp;amp; NPM&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feel Free to contribute on GitHub : &lt;a href="https://github.com/Routine-App/Routine"&gt;https://github.com/Routine-App/Routine&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading! you can support the Routine project directly by r giving it a star on github&lt;br&gt;
GitHub: &lt;a href="https://github.com/Routine-App/Routine"&gt;https://github.com/Routine-App/Routine&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>laravel</category>
      <category>php</category>
    </item>
    <item>
      <title>Build simple Express Js application in 1 minutes with create-express-app</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Wed, 22 Apr 2020 12:07:41 +0000</pubDate>
      <link>https://dev.to/getspooky/build-simple-express-js-application-in-1-minutes-with-create-express-app-nb2</link>
      <guid>https://dev.to/getspooky/build-simple-express-js-application-in-1-minutes-with-create-express-app-nb2</guid>
      <description>&lt;p&gt;Express.js is one of the most popular back-end frameworks nowadays, which lots of people find useful to learn. After mastering the theory, it comes the time to start the practice, and then it may seem a little bit difficult, how to start. But creating your first Express.js application doesn’t have to be so complicated.&lt;br&gt;
Let’s start...&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install create-express-app&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the beginning, we have to install create-express-app tool. which allows installing ready to use Expres.js application, with all needed dependencies. To install the tool, we have to use the following command in the command line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; create-expressjs-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the process finished successfully, you have it installed. Let’s create our app!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create the application&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, it’s super easy to create our first application using the create-express-app tool. We can do it with a single command in our command line. First, navigate to the folder where you want to have your application through the command line, and then run the following command, where expressapp is the name of our application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;create-expressjs-app init expressapp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you create a new app, the CLI will use npm to install dependencies. If you have npm installed, but would prefer to use yarn , you can append --use yarn or -u yarn to the creation command. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;create-expressjs-app init expressapp &lt;span class="nt"&gt;--use&lt;/span&gt; yarn 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will be prompted to pick a template. Supported template are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cra-template-es5 &lt;/li&gt;
&lt;li&gt;cra-template-es6&lt;/li&gt;
&lt;li&gt;cra-template-typescript&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each template comes with a basic &lt;code&gt;Jest&lt;/code&gt; + &lt;code&gt;ESLint&lt;/code&gt; setup.&lt;/p&gt;

&lt;p&gt;You can feel free to set a different name for your application. If the process finished successful, you should have your folder with the app ready! Let’s start the application now!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start the application&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let’s start our expressapp with the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first command is used to enter to the folder of our application, and the second one starts our app. By default, the application is open at localhost:4200&lt;/p&gt;

&lt;p&gt;I hope you will find this tutorial helpful and use it as a base for your first&lt;br&gt;
If you would like to contribute to create-express-app please feel free to check out the Contributing guidelines about how to proceed.&lt;br&gt;
GitHub: &lt;a href="https://github.com/getspooky/create-express-app"&gt;https://github.com/getspooky/create-express-app&lt;/a&gt;&lt;br&gt;
Website: &lt;a href="https://getspooky.github.io/create-express-app/"&gt;https://getspooky.github.io/create-express-app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have a nice coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>node</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Creating &amp; Running Expressjs Projects With create-express-app</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Tue, 21 Apr 2020 22:32:30 +0000</pubDate>
      <link>https://dev.to/getspooky/creating-running-expressjs-projects-with-create-express-app-2acd</link>
      <guid>https://dev.to/getspooky/creating-running-expressjs-projects-with-create-express-app-2acd</guid>
      <description>&lt;p&gt;Create Express App is a command-line interface tool that helps you to initialize, develop and maintain your Expressjs applications. It offers a modern build setup with no configuration. At the same time, it still offers the flexibility to tweak the config of each tool.&lt;br&gt;
Starting new Express projects used to be a huge hassle — there were dozens of dependencies, configuration files, and other up front requirements before you could even start writing a single line of code.&lt;br&gt;
Install it on your machine&lt;br&gt;
You’ll need to have Node &amp;gt;= 8.10 on your local development machine Installation is done using the npm install command:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install -g create-expressjs-app&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;It’s really simple to create a new app — simply run create-expressjs-app followed by the desired name of your application, and it will scaffold a new app for you. Lets try it out:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;create-expressjs-app init my-app&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The folder my-app was created by create-express-app and houses all of our new application's code. The project layout should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;├── README.md
├── node_modules
├── package.json
├── .gitignore
├── public
│   ├── favicon.ico
│   ├── index.html
|   ├── logo64.png
|   ├── logo128.png
│   └── logo256.png
└── src
    ├── App.js
    └── App.test.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Building &amp;amp; running an application&lt;br&gt;
npm start&lt;br&gt;
Runs the app in development mode. Open &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt; to view it in the browser.&lt;br&gt;
npm build&lt;br&gt;
Convert TypeScript or ECMAScript 2015+ code into a backwards compatible version of JavaScript&lt;br&gt;
npm test&lt;br&gt;
Runs the test watcher in an interactive mode.&lt;br&gt;
We encourage you to contribute to create-expressjs-app!&lt;br&gt;
&lt;a href="https://github.com/getspooky/create-express-app"&gt;GitHub&lt;/a&gt;&lt;br&gt;
Happy Coding !&lt;/p&gt;

</description>
      <category>node</category>
      <category>express</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Jibli is a humanitarian initiative that aims to provide free delivery platform due to the coronavirus pandemic 😷😷😷</title>
      <dc:creator>Yasser Ameur el idrissi</dc:creator>
      <pubDate>Tue, 31 Mar 2020 09:03:07 +0000</pubDate>
      <link>https://dev.to/getspooky/jibli-is-a-humanitarian-initiative-that-aims-to-provide-free-delivery-platform-due-to-the-coronavirus-pandemic-48ij</link>
      <guid>https://dev.to/getspooky/jibli-is-a-humanitarian-initiative-that-aims-to-provide-free-delivery-platform-due-to-the-coronavirus-pandemic-48ij</guid>
      <description>&lt;p&gt;We encourage you to contribute to Jibli&lt;br&gt;
GitHub: &lt;a href="https://github.com/getspooky/Jibli"&gt;https://github.com/getspooky/Jibli&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
