<?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>Forem: andreespirela</title>
    <description>The latest articles on Forem by andreespirela (@andreespirela).</description>
    <link>https://forem.com/andreespirela</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%2F402315%2F362e597b-50a8-4904-a175-c76a87582a07.jpeg</url>
      <title>Forem: andreespirela</title>
      <link>https://forem.com/andreespirela</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/andreespirela"/>
    <language>en</language>
    <item>
      <title>How Mandarine Framework could surpass NestJS</title>
      <dc:creator>andreespirela</dc:creator>
      <pubDate>Wed, 28 Oct 2020 20:49:36 +0000</pubDate>
      <link>https://forem.com/andreespirela/how-mandarine-framework-could-surpass-nestjs-13c3</link>
      <guid>https://forem.com/andreespirela/how-mandarine-framework-could-surpass-nestjs-13c3</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Mandarine is a relatively new typescript framework that runs on &lt;a href="https://deno.land" rel="noopener noreferrer"&gt;Deno&lt;/a&gt;. Its objective is very simple: to provide as many built-in functionalities as possible for application development.&lt;/p&gt;

&lt;p&gt;Mandarine is a ready-for-production framework &amp;amp; one of the few packages that are production-ready, and &lt;a href="https://dev.to/andreespirela/why-mandarine-is-by-far-the-best-server-side-framework-in-deno-52dd"&gt;by far, the best server-side framework in Deno&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Mandarine was mainly inspired by &lt;a href="https://spring.io/projects/spring-boot" rel="noopener noreferrer"&gt;Spring Boot&lt;/a&gt; &amp;amp; owns a big set of built-in tools for development such as &lt;a href="https://www.mandarinets.org/docs/master/mandarine/dependency-injection" rel="noopener noreferrer"&gt;Dependency Injection&lt;/a&gt;, &lt;a href="https://www.mandarinets.org/docs/master/mandarine/auth-introduction" rel="noopener noreferrer"&gt;Built-in authentication system&lt;/a&gt;, &lt;a href="https://www.mandarinets.org/docs/master/mandarine/mandarine-query-language" rel="noopener noreferrer"&gt;MQL (Mandarine Query Language)&lt;/a&gt;, &lt;a href="https://www.mandarinets.org/docs/master/mandarine/data-interaction" rel="noopener noreferrer"&gt;ORM (with MQL)&lt;/a&gt;, Built-in session middleware, CORS middleware, and much more.&lt;/p&gt;

&lt;p&gt;For more information about what Mandarine has and why is &lt;em&gt;perhaps&lt;/em&gt; the &lt;strong&gt;best server-side framework&lt;/strong&gt; in Deno, &lt;a href="https://dev.to/andreespirela/why-mandarine-is-by-far-the-best-server-side-framework-in-deno-52dd"&gt;click here&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Mandarine &amp;amp; NestJS
&lt;/h1&gt;

&lt;p&gt;Mandarine &amp;amp; NestJS are perhaps brothers from different mothers, they are really similar in terms of syntax &amp;amp; features, some would definitely argue Mandarine has a much &lt;em&gt;better &amp;amp; simpler&lt;/em&gt; syntax than NestJS, this is because NestJS tends to adopt the Angular pattern of modules while Mandarine only cares about declarations: there's no such thing as a "module" in Mandarine.&lt;/p&gt;

&lt;p&gt;Mandarine does not have the concept of "modules" or "providers", everything is plain declaration of ES6 classes &amp;amp; decorators and it's ready to be used. NestJS on the other hand, abstracts this a little bit more.&lt;/p&gt;

&lt;p&gt;Finally, friendly reminder that Mandarine &amp;amp; NestJS run on different runtimes: Mandarine is for Deno while NestJS for NodeJS.&lt;/p&gt;

&lt;h1&gt;
  
  
  Mandarine: Richer In Functionalities
&lt;/h1&gt;

&lt;p&gt;Mandarine is perhaps richer in functionalities. This does not mean that Mandarine has all the features NestJS has, not at all. This means, Mandarine has many others (and more) built-in tools that make development easier and reduce the boilerplate of many packages with only one goal: Every major functionality you would write in Mandarine &lt;em&gt;should be&lt;/em&gt; a Mandarine-powered feature.&lt;/p&gt;

&lt;p&gt;To explain this a little better, let's look at some of the features Mandarine has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.mandarinets.org/docs/master/mandarine/auth-complete-guide" rel="noopener noreferrer"&gt;Built-in Authentication&lt;/a&gt; (No need to write the logic behind securing endpoints, or authorizing users as it is already provided)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.mandarinets.org/docs/master/mandarine/data-repositories" rel="noopener noreferrer"&gt;Built-in Repositories&lt;/a&gt; (No need to code the logic behind database queries as Mandarine's ORM is fully powered by MQL)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mandarinets.org/docs/master/mandarine/mandarine-query-language" rel="noopener noreferrer"&gt;MQL (Mandarine Query Language)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.mandarinets.org/docs/master/mandarine/session-middleware" rel="noopener noreferrer"&gt;Session Middleware&lt;/a&gt; (No need to use external packages to manage sessions, as it is already built-in in Mandarine with the option to create your own session container)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mandarinets.org/docs/master/mandarine/cors-middleware" rel="noopener noreferrer"&gt;CORS Middleware&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mandarinets.org/docs/master/mandarine/serving-static-content" rel="noopener noreferrer"&gt;Serving Static Content&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mandarinets.org/docs/master/mandarine/built-in-response-time-header" rel="noopener noreferrer"&gt;&lt;code&gt;X-Response-Time&lt;/code&gt; Header Middleware&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.mandarinets.org/docs/master/mandarine/resource-handlers" rel="noopener noreferrer"&gt;Resource Handlers&lt;/a&gt; (Interceptors for different kind of static content)&lt;/li&gt;
&lt;li&gt;Pipes&lt;/li&gt;
&lt;li&gt;Custom Decorators&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And of course, there are a few more features that are important but that is not the purpose of this post.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For more information about Mandarine's feature, visit &lt;a href="https://www.mandarinets.org/docs/master/mandarine/introduction" rel="noopener noreferrer"&gt;its official documentation&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Mandarine surpassing NestJS, Really?
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Extraordinary claims require extraordinary evidence&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Many of you may be thinking, how come a Deno framework could possibly better or more stable than a NodeJS one? &lt;br&gt;
Let's start with some facts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deno is at version 1.5.0, and it's production ready, this has been stated even by Ryan Dahl (Creator of NodeJS &amp;amp; Deno)&lt;/li&gt;
&lt;li&gt;Deno is richer in functionalities.&lt;/li&gt;
&lt;li&gt;There is already room to argue NodeJS and Deno are both good enough for production environments, some would argue Deno is even better since it provides a set of built-in dev tools (like bundling, linting...) &amp;amp; typescript support as first language.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With that said, we can put Mandarine &amp;amp; NestJS at the same level of the discussion in terms of real-world stability.&lt;/p&gt;

&lt;h1&gt;
  
  
  Mandarine's Plan To Be Better... Much Better
&lt;/h1&gt;

&lt;p&gt;Deno has an excellent relation with Rust, in fact, you can connect Rust-written libraries to Deno &amp;amp; call the methods inside those libraries through JS. When you think about it, the limit is the sky. We are talking about direct connection of a very powerful language like Rust (which some argue it's much better and simpler than C++) being called/used from a very popular language like JS. &lt;strong&gt;This is a key for Mandarine's plan of success&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;As stated in &lt;a href="https://www.mandarinets.org/posts/making-mandarine-the-most-stable-framework-with-rust-" rel="noopener noreferrer"&gt;this blog: &lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If Deno is not capable of providing a required feature for stability, we would use Rust again to cover these needs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That means, Mandarine is not only a Typescript framework but will also be powered by Rust.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does this matter ?
&lt;/h3&gt;

&lt;p&gt;Rust is a very popular language (most loved language for 4 years in a row according to &lt;a href="http://stackoverflow.com/" rel="noopener noreferrer"&gt;Stackoverflow&lt;/a&gt;), it has been out there for 10 years, and we can all agree it is very very stable. As a matter of fact, Google is considering integrating it in its V8 engine (&lt;a href="https://www.chromium.org/Home/chromium-security/memory-safety/rust-and-c-interoperability" rel="noopener noreferrer"&gt;Click here for more&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Now with Deno, Rust &amp;amp; Mandarine, Mandarine would connect every requested feature that Deno cannot provide to its Rust core which means, Rust would provide functionalities to Mandarine thus bringing Rust's stability &amp;amp; Rust limitless internal processes to Mandarine (The JS/TS world).&lt;/p&gt;

&lt;p&gt;Quick example of what this means: You want to use Mandarine to modify images, but there are no packages in Deno to do such things (nor Deno provides such functionality). It doesn't matter, Mandarine will provide you a rust application to modify images that you can call from your JS/TS application.&lt;br&gt;
Of course, this is a very vague example, Mandarine's rust core is meant to go along with Mandarine's goals. But I mention this example for a better perspective on what this means.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does this have to do with NestJS &amp;amp; Mandarine?
&lt;/h3&gt;

&lt;p&gt;With the support of Rust, Mandarine can provide functionalities that are yet to exist in Deno &amp;amp; NodeJS, this will give Mandarine advantage in both runtimes.&lt;/p&gt;

&lt;p&gt;One of the main features of NestJS (which Mandarine is missing) are microservices. Microservices in NestJS are entirely coded in Typescript (JS). On the other side, Mandarine could provide a communication-interface for microservices written in Rust but used in the JS side, thus providing performance and more stability in terms of maintenance. &lt;/p&gt;

&lt;h3&gt;
  
  
  Is It Happening Already?
&lt;/h3&gt;

&lt;p&gt;One of the goals Mandarine has had for quiet a long time is to provide a very stable, multi-threaded, database driver not only for Deno but for its internal usage.&lt;/p&gt;

&lt;p&gt;This week, Mandarine came out with &lt;a href="https://deno.land/x/mandarine_postgres@v2.1.6" rel="noopener noreferrer"&gt;&lt;code&gt;Mandarine Postgres&lt;/code&gt;&lt;/a&gt;, a PostgreSQL rust driver that you can use from Deno which officially made Mandarine a framework with mixed codebases.&lt;/p&gt;

&lt;p&gt;This driver makes use of &lt;a href="https://github.com/sfackler/rust-postgres" rel="noopener noreferrer"&gt;&lt;code&gt;tokio-postgres&lt;/code&gt;&lt;/a&gt; under the hood, a widely-used Rust driver for postgres which has been out there for more than 4 years.&lt;/p&gt;

&lt;p&gt;This, again, is one of the examples of "What Deno can't provide, Rust can".&lt;/p&gt;

&lt;h1&gt;
  
  
  The End
&lt;/h1&gt;

&lt;p&gt;This post is not meant to dismiss NestJS awesome work and features rather than presenting both facts &amp;amp; views to how Mandarine &lt;em&gt;could&lt;/em&gt; in the future surpass NestJS in terms of functionality and perhaps stability with the Deno core.&lt;/p&gt;

&lt;p&gt;This post is also meant to show how Deno can get to be more stable than NodeJS in some scenarios, or how packages in Deno can take advantage of Rust for the better.&lt;/p&gt;

&lt;p&gt;The different opinions towards NestJS are just that, opinions. It is up to the reader to interpret this post. While it is true that Mandarine may be at the same level of NestJS, it is also true NestJS has been out there for much more time and it is widely used globally because of the excellent work they have done &amp;amp; provided to different companies around the globe.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fmandarineorg%2Fmandarineorg_web%2Fmaster%2Fapp%2Fmandarine-static%2Fassets%2Fimages%2Fheaders%2Forange.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fmandarineorg%2Fmandarineorg_web%2Fmaster%2Fapp%2Fmandarine-static%2Fassets%2Fimages%2Fheaders%2Forange.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Simple Usage
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.mandarinets.org/docs/master/mandarine/hello-world" rel="noopener noreferrer"&gt;Click here&lt;/a&gt; to see a quick example on how to get started with Mandarine&lt;/p&gt;

&lt;h2&gt;
  
  
  Mandarine on social media
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://twitter.com/mandarinets" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://discord.gg/qs72byB" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fmandarineorg%2Fmandarineorg_web%2Fmaster%2Fapp%2Fmandarine-static%2Fassets%2Fimages%2Fheaders%2Fblack.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fmandarineorg%2Fmandarineorg_web%2Fmaster%2Fapp%2Fmandarine-static%2Fassets%2Fimages%2Fheaders%2Fblack.png"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nestjs</category>
      <category>mandarine</category>
      <category>typescript</category>
      <category>deno</category>
    </item>
    <item>
      <title>Reactive programming in backend</title>
      <dc:creator>andreespirela</dc:creator>
      <pubDate>Wed, 07 Oct 2020 18:01:14 +0000</pubDate>
      <link>https://forem.com/andreespirela/reactive-programming-in-backend-2c2d</link>
      <guid>https://forem.com/andreespirela/reactive-programming-in-backend-2c2d</guid>
      <description>&lt;p&gt;What are some of the use cases you would have for reactive programming in back-end. For front-end, it makes a lot of sense. I just can't see enough examples of how reactive programming is also good for back-end?&lt;/p&gt;

&lt;p&gt;Anything you can think of?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>dev</category>
    </item>
    <item>
      <title>The wait is over, Mandarine 2.0.0 is here.</title>
      <dc:creator>andreespirela</dc:creator>
      <pubDate>Mon, 31 Aug 2020 13:05:09 +0000</pubDate>
      <link>https://forem.com/andreespirela/the-wait-is-over-mandarine-2-0-0-is-here-3g2e</link>
      <guid>https://forem.com/andreespirela/the-wait-is-over-mandarine-2-0-0-is-here-3g2e</guid>
      <description>&lt;p&gt;&lt;a href="https://www.mandarinets.org/"&gt;Mandarine&lt;/a&gt; is an open-source typescript framework that runs on &lt;a href="https://deno.land"&gt;Deno&lt;/a&gt;. Mandarine is used to develop any type of server-side application (Mostly MVC) with the use of strong design patterns such as Dependency Injection, or the SOLID principles.&lt;/p&gt;

&lt;p&gt;From Mandarine's website:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A minimalist, decorator-driven, MVC framework for Deno.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Mandarine is by far the best server-side framework in Deno
&lt;/h2&gt;

&lt;p&gt;If you have not read this article, I highly recommend you reading it in order to have a better ground on the things that will be discussed on this version 2.0.0 presentation post &amp;amp; the reason why's Mandarine is perhaps the most stable framework in Deno.&lt;br&gt;
&lt;a href="https://dev.to/andreespirela/why-mandarine-is-by-far-the-best-server-side-framework-in-deno-52dd"&gt;Click here for the article&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Rich in features
&lt;/h2&gt;

&lt;p&gt;Mandarine &lt;strong&gt;2.0.0&lt;/strong&gt; comes with a ton of built-in features that will make you life easier when it comes to back-end development. Not only these features were created to solve enterprise-level problems but also issues for small-level projects. &lt;br&gt;
&lt;strong&gt;2.0.0&lt;/strong&gt; gives &lt;em&gt;Mandarine&lt;/em&gt; a better position in front of other great frameworks such as &lt;a href="https://nestjs.com/"&gt;NestJS&lt;/a&gt; and makes it clear there is no doubt that Mandarine is production-ready.&lt;br&gt;&lt;br&gt;
Without further ado, let's get to it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Built-in Authentication System&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mandarine provides a built-in authentication system. With this system you no more have to worry about creating endpoints such as login &amp;amp; logout. Or, creating the logic necessary to protect different endpoints in your application. Following Mandarine's built-in authentication guide will make your application more secure and it will all be handled by the framework, saving you not only time, but security concerns and lines of code. There is a complete guide on &lt;a href="https://www.mandarinets.org/docs/master/mandarine/introduction"&gt;Mandarine's documentation page&lt;/a&gt; under "Mandarine Security" you will find the documentation of &lt;a href="https://www.mandarinets.org/docs/master/mandarine/auth-introduction"&gt;"Authentication"&lt;/a&gt;. &lt;a href="https://www.mandarinets.org/docs/master/mandarine/auth-complete-guide"&gt;Click here to see a full example&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;This system was mainly inspired by the great work of Spring Boot Framework in Java.&lt;/li&gt;
&lt;li&gt;This feature puts Mandarine ahead of many other typescript/javascript frameworks out there.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Pipes&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mandarine now provides the concept of &lt;code&gt;Pipes&lt;/code&gt; for &lt;a href="https://www.mandarinets.org/docs/master/mandarine/http-handlers"&gt;HTTP Parameter Decorators&lt;/a&gt;. Pipes can process and return a new/processed value before it gets to the HTTP Handler, cleaning your data during request time without any boilerplate. &lt;a href="https://www.mandarinets.org/docs/master/mandarine/pipes"&gt;Read more about Pipes here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Custom Decorators&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mandarine now provides a decorator factory which lets you create your own &lt;em&gt;HTTP Parameter Decorators&lt;/em&gt;. This is useful when wanting to avoid boilerplate of utility classes or helpers. The use cases of this are many, hopefully you will find one!. &lt;a href="https://www.mandarinets.org/docs/master/mandarine/custom-decorators"&gt;Read more about Custom Decorators here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those are the main 3 features Mandarine provides in its &lt;strong&gt;2.0.0&lt;/strong&gt; version. Although, many were included in this release such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Middleware targeting specific controllers or HTTP Handlers. &lt;a href="https://www.mandarinets.org/docs/master/mandarine/use-middleware-decorator"&gt;See here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Non-component middleware. &lt;a href="https://www.mandarinets.org/docs/v2.0.0/mandarine/non-component-middleware"&gt;See here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Exception filters. &lt;a href="https://www.mandarinets.org/docs/v2.0.0/mandarine/catch"&gt;See here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Security Expressions. &lt;a href="https://www.mandarinets.org/docs/v2.0.0/mandarine/security-expressions"&gt;See here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And many more. If you are interested in finding out a complete overview on what is new in Mandarine &lt;strong&gt;2.0.0&lt;/strong&gt;, &lt;a href="https://github.com/mandarineorg/mandarinets/releases/tag/v2.0.0"&gt;Click here on the official release page&lt;/a&gt; and take a look.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mf7jgvIN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/mandarineorg/mandarineorg_web/master/app/mandarine-static/assets/images/headers/orange.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mf7jgvIN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/mandarineorg/mandarineorg_web/master/app/mandarine-static/assets/images/headers/orange.png" width="300" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Simple Usage
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.mandarinets.org/docs/master/mandarine/hello-world"&gt;Click here&lt;/a&gt; to see a quick example on how to get started with Mandarine&lt;/p&gt;

&lt;h2&gt;
  
  
  Mandarine on social media
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://twitter.com/mandarinets"&gt;Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://discord.gg/qs72byB"&gt;Discord&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GrQRcQ37--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/mandarineorg/mandarineorg_web/master/app/mandarine-static/assets/images/headers/black.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GrQRcQ37--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/mandarineorg/mandarineorg_web/master/app/mandarine-static/assets/images/headers/black.png" width="300" height="300"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a href="https://github.com/mandarineorg/mandarinets/releases/tag/v2.0.0"&gt;Release Page Here&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Comments, question? Below.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>typescript</category>
      <category>deno</category>
      <category>framework</category>
    </item>
    <item>
      <title>Why Mandarine is by far the best server-side framework in Deno</title>
      <dc:creator>andreespirela</dc:creator>
      <pubDate>Sat, 15 Aug 2020 13:47:09 +0000</pubDate>
      <link>https://forem.com/andreespirela/why-mandarine-is-by-far-the-best-server-side-framework-in-deno-52dd</link>
      <guid>https://forem.com/andreespirela/why-mandarine-is-by-far-the-best-server-side-framework-in-deno-52dd</guid>
      <description>&lt;p&gt;&lt;a href="http://mandarinets.org/"&gt;Mandarine&lt;/a&gt; is an open-source typescript framework that runs on &lt;a href="https://deno.land"&gt;Deno&lt;/a&gt;. Mandarine is used to develop any type of server-side application (Mostly MVC) with the use of strong design patterns such as Dependency Injection, or the SOLID principles.&lt;br&gt;&lt;br&gt;
From Mandarine's website:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A minimalist, decorator-driven, MVC framework for Deno.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;On this post, we will cover why Mandarine is perhaps, the &lt;strong&gt;best server-side framework&lt;/strong&gt; in the Deno community. I admit, it's a hot take to describe Mandarine as such, but I will defend these points throughout the post.&lt;/p&gt;
&lt;h1&gt;
  
  
  Deno, not NodeJS.
&lt;/h1&gt;

&lt;p&gt;We have to start from this point. NodeJS as you may already know is meant to work with Javascript and yes, you can make it compatible with Typescript as well, but NodeJS itself was not created under a Typescript paradigm. Unlike Deno, Deno was fully created to support typescript out of the box, most Deno applications are written in Typescript and this will continue to be this way. As Ryan Dahl (Creator of both NodeJS &amp;amp; Deno) stated:  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WYgym3td--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/05tg62plwggyguuvwi21.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WYgym3td--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/05tg62plwggyguuvwi21.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The reason I address this is because I keep seeing packages in Deno that are written in Typescript but they have the same kind of code a Javascript code could have &amp;amp; this is really an issue because people are just trying to think in a "Javascript way" inside a Typescript environment which definitely stops the development of more powerful features &amp;amp; stops the limits of our imagination in a Typescript environment. I keep seeing people coding the "equivalent" of a NodeJS package in Deno and while this may be good at some extend, I can't stand the fact that the "Javascript way" is being kept in many Deno packages. &lt;/p&gt;

&lt;p&gt;Mandarine &lt;strong&gt;changes this&lt;/strong&gt;. Mandarine takes advantage of every single feature Typescript has to offer, from generic classes inside Mandarine's core, to the use of Decorators &amp;amp; Metadata reflection for the creation of Mandarine-powered applications.&lt;br&gt;
Mandarine tries to get as far away as possible from a &lt;em&gt;Javascript thinking&lt;/em&gt; in a &lt;em&gt;Typescript runtime&lt;/em&gt;. Typescript really are not just Types, Typescript has an extensive core of solutions for design-patterns and functionalities that many developers are not taking advantage of which is something Mandarine is looking forward to changing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lWJ35fbm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9ywuluoho055p5ejixb6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lWJ35fbm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9ywuluoho055p5ejixb6.png" alt="A simple quickstart for Mandarine"&gt;&lt;/a&gt;&lt;br&gt;
(A simple quickstart in Mandarine)&lt;/p&gt;
&lt;h1&gt;
  
  
  Strong Design Patterns
&lt;/h1&gt;

&lt;p&gt;Mandarine believes in the strong use of Design Patterns as well as the benefits of Object-Oriented programming. Mandarine makes use of two important design patterns: &lt;strong&gt;Dependency Injection&lt;/strong&gt; &amp;amp; &lt;strong&gt;MVC&lt;/strong&gt; in order to provide the most &lt;em&gt;SOLID&lt;/em&gt; development.&lt;/p&gt;

&lt;p&gt;Mandarine is well-known because of its dependency injection system. Among only 3 frameworks that support Dependency Injection in Deno, Mandarine has perhaps the most stable approach. It allows dependency injection by both construction-based &amp;amp; property-based with the benefit of property-based injection not having to specify what type we are trying to inject like in &lt;a href="https://angular.io/guide/hierarchical-dependency-injection"&gt;Angular&lt;/a&gt; or &lt;a href="https://docs.nestjs.com/fundamentals/injection-scopes"&gt;NestJS&lt;/a&gt; where property injection &lt;strong&gt;needs&lt;/strong&gt; to receive a &lt;strong&gt;token (type)&lt;/strong&gt;. Also, another &lt;strong&gt;+1&lt;/strong&gt; for Mandarine's dependency injection system is the fact there is no such thing as a "Module": If you come from Angular or NestJS for back-end, you will know dependencies usually go under the concept of "Module" and through Modules is the way your application communicates with other components. In Mandarine such concept does not exist since everything in Mandarine is either a Mandarine-powered component or not and so by the time you use the dependency declarator-decorators such as &lt;code&gt;@Controller&lt;/code&gt;, &lt;code&gt;@Service&lt;/code&gt;, &lt;code&gt;@Component&lt;/code&gt;, &lt;code&gt;@Configuration&lt;/code&gt; or &lt;a href="https://www.mandarinets.org/docs/master/mandarine/components"&gt;others&lt;/a&gt;  that component is immediately available for injection at other Mandarine-powered components. If you come from a Java environment, you probably know about &lt;a href="https://spring.io/"&gt;Spring Boot&lt;/a&gt;, most likely, you have used. Mandarine uses the same concept of dependency injection that Spring Boot has.&lt;/p&gt;
&lt;h1&gt;
  
  
  Built-in Tools
&lt;/h1&gt;

&lt;p&gt;Mandarine has a set of built-in tools that allow back-end development to be easier, not only in terms of design patterns as we mentioned before, but in terms of common features that are highly used. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Template Engine: Mandarine supports &lt;a href="https://ejs.co/"&gt;EJS&lt;/a&gt; &amp;amp; &lt;a href="https://handlebarsjs.com/"&gt;Handlebars&lt;/a&gt; out of the box. &lt;a href="https://www.mandarinets.org/docs/master/mandarine/template-engine"&gt;More about Mandarine's template engine here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Session Middleware: Mandarine has full support for session middleware (including a default in-memory implementation &amp;amp; the possibility to re-write this implementation). &lt;a href="https://www.mandarinets.org/docs/master/mandarine/session-middleware"&gt;See more here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;CORS Middleware: Mandarine has a CORS middleware out of the box that is not only available for endpoints but also for resources. &lt;a href="https://www.mandarinets.org/docs/master/mandarine/cors-middleware"&gt;See more here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Static Content: Mandarine has full support for static-content serving, fully customizable. &lt;a href="https://www.mandarinets.org/docs/master/mandarine/serving-static-content"&gt;See more here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Resource Handlers: Mandarine has full support for adding, overriding and creating Resource Handlers. Resource Handlers are the logic behind serving static content. The possibility to customize the behavior of this allow different interpretation and outcomes for different types of URL, for exmaple, with Resource Handlers you could add a logic to process all the &lt;code&gt;.xml&lt;/code&gt; files and convert them to &lt;code&gt;.json&lt;/code&gt; by the time of the request. &lt;a href="https://www.mandarinets.org/docs/master/mandarine/resource-handlers"&gt;See more here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;ORM: Mandarine has a built-in ORM which takes away the complexity of writing SQL queries or the complexity of having chain-like ORM's. Mandarine brings the concept of &lt;a href="https://www.mandarinets.org/docs/master/mandarine/mandarine-query-language"&gt;MQL (Mandarine Query Language)&lt;/a&gt; to write complex queries.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Built-in ORM
&lt;/h1&gt;

&lt;p&gt;Mandarine's built-in ORM is perhaps my favorite feature. It allows you to write SQL queries in the same way you would in frameworks like &lt;em&gt;Spring Boot&lt;/em&gt;. With the concept of MQL, much of the functional (or SQL) boilerplate code is taken away.&lt;/p&gt;

&lt;p&gt;Where&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;findByAirlineAndPassengerName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;airline&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="nx"&gt;passengerName&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;is transformed into&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="p"&gt;....&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;airline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;passengerName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;

&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;airline&lt;/span&gt; &lt;span class="k"&gt;parameter&lt;/span&gt;
&lt;span class="o"&gt;#&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;passengerName&lt;/span&gt; &lt;span class="k"&gt;parameter&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here is a clear implementation of how this works:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ceTaenSj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/aaw5slh6f3exwngusin8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ceTaenSj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/aaw5slh6f3exwngusin8.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information about Mandarine's built-in ORM &lt;a href="https://www.mandarinets.org/docs/master/mandarine/data-interaction"&gt;Click here&lt;/a&gt;&lt;br&gt;
For more information about Mandarine's MQL &lt;a href="https://www.mandarinets.org/docs/master/mandarine/mandarine-query-language"&gt;Click here&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Native Components
&lt;/h1&gt;

&lt;p&gt;Mandarine brings the concept of Native Components to Typescript. Native components are classes that Mandarine uses as default to boost the framework. These classes usually have some sort of information related to the different behaviors of the framework. For example, in Mandarine, there is the native component &lt;code&gt;WebMvcConfigurer&lt;/code&gt; which has the behavior of how the session container (for the session middleware) will behave, it also has information about the default &lt;em&gt;resource handlers&lt;/em&gt; (used for serving static content). With the concept of Native Components, Mandarine allows the developer to override (through &lt;code&gt;@Override&lt;/code&gt;) and establish custom behaviors in a &lt;em&gt;OOP&lt;/em&gt; way, making it not only straightforward but readable in terms of lines of code to execute such thing.&lt;br&gt;&lt;br&gt;
&lt;a href="https://www.mandarinets.org/docs/master/mandarine/native-components"&gt;See more about native components here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ymXXSt7b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/618by7gv4srfycye9xl1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ymXXSt7b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/618by7gv4srfycye9xl1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h1&gt;
  
  
  Decorator-driven
&lt;/h1&gt;

&lt;p&gt;Many of you may know the express syntax, which is something like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/route&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;context&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This syntax is widely used in the NodeJS community as well as the Deno community. In Deno, we have several frameworks that take use this approach such as &lt;a href="https://github.com/oakserver/oak"&gt;Oak&lt;/a&gt; or &lt;a href="https://github.com/sholladay/pogo"&gt;Pogo&lt;/a&gt;. While this approach may be found straightforward, it really sticks to the way we write javascript &amp;amp; as I mentioned before, I believe a Typescript ecosystem should make use of all its Typescript features, otherwise, what's the point behind using typescript really?. Mandarine takes a different view and creates your routes through the use of decorators such as &lt;code&gt;@GET&lt;/code&gt;, &lt;code&gt;@POST&lt;/code&gt; and so on, similar to &lt;em&gt;NestJS&lt;/em&gt; or &lt;em&gt;Spring Boot&lt;/em&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  2.0.0
&lt;/h1&gt;

&lt;p&gt;Just to make the last remark about why Mandarine is perhaps the best server-side framework by far in Deno, Mandarine has announced the list of features that will be available in version 2.0.0 (expected to land during last week of August 2020, or first two weeks of September 2020). These features include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Native support for built-in authentication &amp;amp; user handling.&lt;/li&gt;
&lt;li&gt;Custom Decorators&lt;/li&gt;
&lt;li&gt;Exception Filters&lt;/li&gt;
&lt;li&gt;Pipes&lt;/li&gt;
&lt;li&gt;Guards&lt;/li&gt;
&lt;li&gt;CRON Jobs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can read more about these features and what they mean &lt;a href="https://www.mandarinets.org/posts/what-s-coming-for-2-0-0"&gt;in this blog&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;We have deeply analyzed some of the most important features that divide Mandarine from the rest of server-side frameworks in Deno. The opinions behind whether Mandarine is really the best server-side framework in Deno will be different for every person, although we can state the fact that Mandarine accomplishes a better interaction between a modular application through enforcing principles such as SOLID or MVC. On the other hand, a opinion-driven thought is whether enforcing OOP programming and making use of all typescript features is really a good thing. Some would argue that Javascript is the way it is and it should be written that way, my take really goes to: If Javascript is what it is, why did we even invent Typescript?, and what I'm saying with this is that in a Typescript environment, you should think in a Typescript way: interpreting Typescript as &lt;strong&gt;only types&lt;/strong&gt; is fundamentally wrong.&lt;/p&gt;

&lt;p&gt;This post is not meant to cause any controversy on the different contributions people have made to Deno rather than presenting both facts &amp;amp; views to how Mandarine can get to solve different issues in a enterprise-like way, not only technically speaking but also theoretically speaking.&lt;/p&gt;

&lt;p&gt;The different comparisons made to different frameworks such as Angular, NestJS, Pogo or Oak do not refer to facts rather than opinions on what a &lt;em&gt;better&lt;/em&gt; approach looks like. While it is true that these frameworks do things the way they do it for a specific reason which has been thought by knowledgeable developers, it is also true that every approach can have a better approach which is exactly what I am dressing in the different comparisons and their final objective.&lt;/p&gt;

&lt;p&gt;It is clear that every developer has a preference towards a coding style, some will prefer decorators, others would prefer functional-like declaration. Every opinion on the matter is of course appreciated by this post.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Want to know more about Mandarine?&lt;/strong&gt;: Try &lt;a href="https://www.mandarinets.org/docs/master/mandarine/hello-world"&gt;Mandarine's quickstart example&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thoughts? I'd like to know them, comment below.&lt;br&gt;
Questions? I'd like to answer them, ask below in the comments section.&lt;/p&gt;

</description>
      <category>framework</category>
      <category>deno</category>
      <category>typescript</category>
      <category>backend</category>
    </item>
    <item>
      <title>Writing a framework. PT I</title>
      <dc:creator>andreespirela</dc:creator>
      <pubDate>Tue, 07 Jul 2020 16:53:31 +0000</pubDate>
      <link>https://forem.com/andreespirela/writing-a-framework-pt-i-5g19</link>
      <guid>https://forem.com/andreespirela/writing-a-framework-pt-i-5g19</guid>
      <description>&lt;p&gt;Over the last few months of 2020, I have dedicated myself to writing &lt;a href="https://github.com/mandarineorg/mandarinets"&gt;MandarineTS Framework&lt;/a&gt;. It has been an amazing journey where I have met really knowledgeable people &amp;amp; have participated in the &lt;a href="https://deno.land"&gt;Deno&lt;/a&gt; community more actively. &lt;br&gt;
I never thought I would be participating in such a large open source community but more than participating, I never thought I was going to collaborate in some sort of way. &lt;/p&gt;

&lt;p&gt;Participating in Open-Source projects have been one of the most &lt;strong&gt;honorable&lt;/strong&gt; experiences I have had: I have interacted with really important people in the computer science world (theoretically speaking), and this gives you not only a new way to look at your code &amp;amp; your reasons to code but it also opens your mind to where you want to go &amp;amp; offers you a better sense of how important your work can get to be.&lt;/p&gt;

&lt;p&gt;On this post, I will be discussing the details of creating a framework: &lt;em&gt;The concept &amp;amp; the reason, the basis of it, the core, what I have learned, what I regret, and how to maintain it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This first part will only be about main concepts we need to know in order to create a framework. I will be posting a second and probably a third part where we will creating &lt;strong&gt;our own dependency injection framework&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Without further ado, let's get to it.
&lt;/h4&gt;

&lt;h2&gt;
  
  
  The Concept &amp;amp; The Reason
&lt;/h2&gt;

&lt;p&gt;Most of the things you think you can create &lt;em&gt;are already created&lt;/em&gt;. Under that scenario, you have to think what is your added value, for example: You may pretty well offer the same things with better performance &amp;amp; syntax, or you may pretty well offer new things with the same performance &amp;amp; same syntax. In most cases, &lt;strong&gt;this is not worth it&lt;/strong&gt;. The amount of time it requires and the very little usability you may get will not make it worth it.  &lt;/p&gt;

&lt;p&gt;But let's say you have either decided to continue no matter whether it's already created, or you have an awesome idea. The first thing you need to consider and have a pretty clear perspective about is an answer for the following question: &lt;em&gt;What problem are you trying to solve?&lt;/em&gt;. Such question will be the one to lead you to structure your framework. You need to have a pretty solid idea of what your code will be solving because before starting to code, you already need to know how your framework will be distributed, you need to consider the performance aspects, whether you will use third party libraries, the problems of your current runtime, the limitations of the language you will use, and more &lt;strong&gt;fundamental questions&lt;/strong&gt; we will be reviewing.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I created Mandarine because there was nothing alike in Deno. In the case of NodeJS, Mandarine is pretty similar to NestJS, but in Deno, this was an unique opportunity to bring the MVC pattern &amp;amp; a decorator-driven development style as the &lt;em&gt;Deno&lt;/em&gt; community is growing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Basis of Creating a Framework
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Now, let's get to the technical side.
&lt;/h4&gt;

&lt;p&gt;When creating a framework, you need to have a &lt;em&gt;deep understanding&lt;/em&gt; of both coding skills and fundamental skills (knowing how to code, why to code it, and the impact it has on the computer your code is running). You also need to have a deep understanding of the different environments that we have in software such as &lt;strong&gt;Develop environment&lt;/strong&gt; &amp;amp; &lt;strong&gt;Production environment&lt;/strong&gt;, this is because, if you are creating a framework, its objective will be to be used in a production environment where multiple instances (servers) and concurrent requests are constantly ongoing, this is something you need to consider how to handle when writing the first part of your code. If you leave these details out, &lt;strong&gt;you will regret&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture
&lt;/h3&gt;

&lt;p&gt;Building a framework requires an architecture, this means, you will need to think what design patterns you will use, you will need to come up with your own standards in order to have the same kind of code when collaborators join, or even for yourself. You need to establish a line between the language you are using, the runtime and your framework. You will not use all the features of the language and/or runtime you are using, and this is important because you &lt;strong&gt;should not&lt;/strong&gt; use all the features, you should only use what you will be needing. Do not get fancy or hacky to do things, that really does not make your code better.&lt;/p&gt;

&lt;h4&gt;
  
  
  Naming conventions
&lt;/h4&gt;

&lt;p&gt;You should maintain the same naming conventions across the framework. I personally like camel case, but this depends on the developer. Make sure you follow this, it will help when your code grows.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For example, &lt;em&gt;Mandarine&lt;/em&gt; does not use a &lt;strong&gt;deps.ts&lt;/strong&gt; file where all the exports of the different dependencies are located for the modules. I did it this way because every file should import the dependencies it will use, it should not use a "index" file for dependencies. if an "index" file for dependencies such as &lt;em&gt;deps.ts&lt;/em&gt; is used, the risk of a code breaking all your modules grow. Instead, when importing manually the dependencies your file will use, you gain more control over that, and if a module breaks your application, it is easier to find the root of the cause.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The core
&lt;/h3&gt;

&lt;p&gt;Every framework has a core, &lt;em&gt;needs&lt;/em&gt; a core. Your framework will need a core too. The core is just that, a core. It will connect the basis of your framework to all the different modules, it will be responsible for loading &amp;amp; initializing the different components that are needed for it to work out. &lt;em&gt;For example&lt;/em&gt;, if you are writing a &lt;em&gt;dependency injection framework&lt;/em&gt; (&lt;strong&gt;DI&lt;/strong&gt;), then your core will be responsible for creating &amp;amp; injecting all the instances.&lt;br&gt;
The core should stick to core functionalities, for example: If your framework is to create an HTTP Server, the HTTP Dispatcher (Creation of routes, initialization of the HTTP Server, etc) should not go inside the core, instead, your framework would need a module called &lt;strong&gt;"http-dispatcher"&lt;/strong&gt; that will handle this kind of things &amp;amp; the core will provide it with the necessary functionalities as the core will work as a bridge for your framework. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The core is the most important part of a framework as it handles everything that is needed. It will be possible the module that has more lines of code (LOC). In Mandarine, the &lt;a href="https://github.com/mandarineorg/mandarinets/tree/master/main-core"&gt;core&lt;/a&gt; contains the decorators that the developer will be likely to use, the interfaces, the DI factory and the DI container, it also contains all the exceptions that are originally thrown from Mandarine &amp;amp; utility classes that are used across the other modules.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The Other Modules
&lt;/h3&gt;

&lt;p&gt;Your framework will probably have more modules than just the core, this is where things will start getting messier. The more modules you have the more code you have, this affects performance at both compile (more time to compile your code) &amp;amp; runtime (it can take many resources if your code is not well-written, along with other aspects).&lt;br&gt;
With that said, when having other modules than just the core, you always need to think how to make everything re-usable across your framework: You need to make everything you can a utility method or class, do not over code, do not repeat code. Try to centralize things such as Similar interfaces or similar classes, make use of generics, make use of class-extension. The cleaner your code is, the easier it will be to maintain and the better it will be for performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do not &lt;em&gt;framework&lt;/em&gt; your framework
&lt;/h3&gt;

&lt;p&gt;This is something you must be really careful of. Do not use your framework's functionalities inside the core or modules of your framework. Your framework &lt;strong&gt;must only&lt;/strong&gt; provide functionality to the developer who is using it, but it should not provide functionality to itself. Your framework should be written as natively as possible, meaning, as self-dependent as possible. This practice of a self-dependent framework increases testability, readability, and decrease the boilerplate and risk of breaking.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For example, Mandarine has a DI Framework, although, Mandarine &lt;strong&gt;does not&lt;/strong&gt; use its DI framework inside the core, everything in Mandarine is Javascript/Typescript native.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Think globally, not for yourself.
&lt;/h3&gt;

&lt;p&gt;When creating a framework, after you release the first version, you have to start thinking &amp;amp; assuming many people are using your framework by now. It's important to have this kind of thinking because it will make you carefully consider every single change: &lt;strong&gt;You do not want your framework to break other's people applications&lt;/strong&gt;.&lt;br&gt;
Avoid breaking changes as much as you can. Breaking changes can have a huge impact on other people's code. The new features you add &amp;amp; the bugs you fix should not alter the behavior of what is out there that people are using.&lt;br&gt;
Yes, you can have breaking changes. Any project has breaking changes, in fact, breaking changes are something really common during the early versions of any program, but... avoid them. &lt;br&gt;
Always your framework is being used in production, thus, you need to be thoughtful when it comes to changing the structure of something, the syntax of something, when removing a method from the code, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I have learned
&lt;/h2&gt;

&lt;p&gt;Creating &lt;a href="https://github.com/mandarineorg/mandarinets"&gt;Mandarine&lt;/a&gt; has given me a lot of stories to tell, a lot of experience to be shared. One of the main things I have struggled while creating Mandarine is being consistent with design patterns &amp;amp; self-dependency for modules. Mandarine lacked design patterns during its first days, after several versions being released, this has improved. Mandarine's code is more consistent &amp;amp; has more design patterns, yet, it's still a process where I find myself always refactoring and thinking carefully what is the best approach to add a feature or solve a bug, since every single line of code can affect the consistency of the design patterns mandarine makes use of.&lt;br&gt;
Another thing I would say I have learned is the importance of self-dependency modules. During the very very very early versions of Mandarine, Mandarine was hard to unit-test because all the modules had some sort of relation with the other modules, but as of right now, things have gotten easier as Mandarine is now using the proxy design pattern which wraps all core methods and functionalities in classes called Proxy, so the calls to a method are always made to the proxy and the proxy validates and then calls the requested method. This has made not only performance get better, but it has also made the code more readable and testable.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I regret
&lt;/h2&gt;

&lt;p&gt;This is an interesting questions because I don't really have regrets that can be used as a useful experience when writing a framework. But I do have to say, not everything has been pretty with Mandarine. If I could go back to when I started writing it, I would tell myself to establish design patterns because the amount of code refactoring that is coming on my way is incredible (I have refactored the whole core of Mandarine 4 times, only because I didn't consider design patterns in the beginning).&lt;br&gt;
I do think I could have made a better job writing unit tests, at the very beginning I didn't write unit tests for Mandarine. It is now that Mandarine is starting to have unit tests for every of its modules, it's been a long process writing these unit tests as Mandarine has grown significantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  How To Maintain a Open-Source Framework
&lt;/h2&gt;

&lt;p&gt;When I started with Mandarine, I felt really uncertain about how to maintain an open-source framework, and sometimes I still do because there's a lot to learn everyday for everyone, for me too, the community is always evolving &amp;amp; you need to adapt faster every time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Develop branch &amp;amp; Master Branch
&lt;/h3&gt;

&lt;p&gt;Your Master branch is the branch you have to protect the most. The master branch must always, always be stable. For this, I always recommend the following:&lt;br&gt;
Create two branches: Master &amp;amp; Develop. Your main code/last release code will be always located under Master. The code for feature releases (features, bug fixes, etc) will be always be worked on Develop. When the release is ready and develop is stable, you merge Develop into master and then you create the release from master. From there, you continue to work on develop for anything that you want following the same process. Develop can get to be unstable, master &lt;strong&gt;must never be&lt;/strong&gt; unstable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Versioning
&lt;/h3&gt;

&lt;p&gt;Your versioning needs to be meaningful (&lt;strong&gt;MAJOR.MINOR.PATCH&lt;/strong&gt;). You can't just release whatever number looks good, it is important to keep consistency &amp;amp; meaning of your versions. If something is a patch then it should affect the patch numbering, if an update includes many patches and features that affect many modules then it can be considered a minor, if there is a list of features &amp;amp; fixes that have been constantly released, and there is a big change that affect your framework at all levels then it can be considered a major update.&lt;br&gt;
You also need to have a release plan, although this is a complex subject, the basic of it is, you need to know what each version will have, you can't just add anything to any version. You need to plan releases ahead, this way you can know what you have to code per release, you organize your framework more, it's less time consuming than just coding and releasing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Issues
&lt;/h3&gt;

&lt;p&gt;You should open issues to any feature/bug fix/other you are going to work on. This is because, the more documented a framework is, the better. Issues represent documentation to a specific problem at a specific period of time. These issues should have a context of why it is being done, and if it is a bug, these issues should have information about that bug. Don't code without an issue, open an issue if necessary.&lt;/p&gt;

&lt;h3&gt;
  
  
  Docs
&lt;/h3&gt;

&lt;p&gt;Your framework should be extremely documented as mentioned before, don't expect people to know how to use it, be as explicit as you can, and document every single feature your framework has and how to use it in different scenarios. Also, don't only document code, &lt;strong&gt;document concepts&lt;/strong&gt;. The concept of why something is made that way, why something exists inside your framework, what it does, when it can fail, everything about it is as important as the code. You don't really do anything with just documenting the code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Guidelines
&lt;/h3&gt;

&lt;p&gt;Your framework should have guidelines (Check the &lt;a href="https://github.com/mandarineorg/mandarinets/blob/master/docs/contributing.md"&gt;contributing guidelines of Mandarine here&lt;/a&gt; &amp;amp; &lt;a href="https://github.com/mandarineorg/mandarinets/blob/master/docs/style_guide.md"&gt;Style guide here&lt;/a&gt;)&lt;/p&gt;

&lt;h3&gt;
  
  
  Bug reporting
&lt;/h3&gt;

&lt;p&gt;When you want to report a bug to yourself, or someone is reporting a bug, you &lt;strong&gt;must&lt;/strong&gt; always have the basic information of that bug:&lt;br&gt;
Operative System, version of the runtime, version of your framework, etc. This will help you find the cause quicker.&lt;/p&gt;

&lt;h1&gt;
  
  
  The end
&lt;/h1&gt;

&lt;p&gt;This is the end of "Writing a framework" part number 1. As I mentioned before, I will be creating a second and probably third part to use the concepts we went over this post programmatically. We will be creating our own DI Framework (a simple one) but that will give you a better understanding of what a core is, etc.&lt;/p&gt;

&lt;p&gt;Question/Feedback? Please &lt;strong&gt;comment below&lt;/strong&gt; :)&lt;/p&gt;

</description>
      <category>mandarine</category>
      <category>typescript</category>
      <category>deno</category>
      <category>framework</category>
    </item>
    <item>
      <title>What has made me more efficient</title>
      <dc:creator>andreespirela</dc:creator>
      <pubDate>Fri, 26 Jun 2020 23:31:39 +0000</pubDate>
      <link>https://forem.com/andreespirela/what-has-made-me-more-efficient-adm</link>
      <guid>https://forem.com/andreespirela/what-has-made-me-more-efficient-adm</guid>
      <description>&lt;p&gt;Throughout my years of programming, I have gone through different phases, phases that have shaped me as a developer and the personal side of being a developer. At first, being efficient was a challenge: When you are just getting into programming you want to do everything at the same time, and your thoughts are just like constant explosions in your brain.&lt;/p&gt;

&lt;p&gt;What I am going to share today is not scientifically proved nor a fact, it is an opinion &amp;amp; perspective on how things have turned out for me.&lt;/p&gt;

&lt;p&gt;When I started programming, I used to ask myself a lot of things, "&lt;strong&gt;How does that website work?&lt;/strong&gt;", "&lt;strong&gt;How can I make a login page?&lt;/strong&gt;", "&lt;strong&gt;How is a programming language created?&lt;/strong&gt;". There were just so many questions that my brain &lt;strong&gt;didn't&lt;/strong&gt; get enough rest. At night while laying on my bed, these questions used to come up and bother me thus making me &lt;strong&gt;sleepless&lt;/strong&gt;. Learning how to control this kind of behaviors was a difficult task but not impossible, and at the end, it was necessary to control this because &lt;strong&gt;my life-balance was out of balance&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When programming started to be clear, fluent &amp;amp; more natural in my mind, then the issue was not only about the questions but now there was a new issue: &lt;strong&gt;I wanted to be always coding&lt;/strong&gt;, at first, I thought that was a good idea, like "&lt;em&gt;Yes, I'll stop coding at 5am, to then wake up at 10am and keep coding&lt;/em&gt;" and for a while it gave some results, but I knew there has to be something wrong, If programming was so tiring in the same way I was exercising it, then nobody would be a programmer.&lt;/p&gt;

&lt;h1&gt;
  
  
  What I have learned
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Routine is your best friend:
&lt;/h3&gt;

&lt;p&gt;I discovered that my efficiency improved in impressing ways when I started getting a routine, not a routine in programming but a routine in general. I started waking up at the same time everyday and I started falling asleep at the same time everyday. If I forced myself to have period of times where I could code and period of times where I had to stop coding. &lt;br&gt;
For example: I would allow myself to code anytime from 9am to 8pm but after 8pm I would have to get a distraction of some sort.&lt;/p&gt;

&lt;h3&gt;
  
  
  Issues can wait
&lt;/h3&gt;

&lt;p&gt;Many times we run into issues and we feel like we have to solve them right away, and trust me, I know the feeling of self-satisfaction when we solve an important issue or when we solve something we didn't understand why it was happening in the first place. Sometimes this behavior of wanting to code code and code leads to "solving, solving and solving". But really, issues can wait. In the same way you &lt;em&gt;should&lt;/em&gt; have a routine, you should be powerful enough to tell yourself "I am going to fix this tomorrow" or "I am going to fix this over the weekend". This will provide you with life-balance and code-balance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Read, don't code.
&lt;/h3&gt;

&lt;p&gt;Many times, when I am going through my period where I don't allow myself to code (ex, after 8pm or before 9am) but I want to code, and I want it so badly, I just start reading articles about coding, things such as &lt;strong&gt;best practices&lt;/strong&gt;, &lt;strong&gt;new trends&lt;/strong&gt;, &lt;strong&gt;discussions&lt;/strong&gt;, and more. Reading about coding while not coding is actually really good, it makes your brain have a better flows of ideas &amp;amp; solutions to possible issues you have, and since your brain is not working so hard as it is when coding, you can perceive and understand the readings better.&lt;/p&gt;

&lt;h3&gt;
  
  
  Get an uncomfortable habit
&lt;/h3&gt;

&lt;p&gt;This is a weird one but perhaps the second most important one for me. When I am coding, I always have a bottle of water that I throw from hand to hand, kind of passing a ball from one hand to the other. I do this with a bottle of water, with my wallet, with anything that has a curve pretty much. This is because when I am coding &amp;amp; thinking I feel anxious and I feel the need to get that anxiety out of me. At first, it seemed like I was crazy just throwing things from one hand to the other, after a while, it became a way to have my mind thinking and my body doing something without having to walk or do something even more distracting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finally &amp;amp; the most important for me&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Get away from electronic devices
&lt;/h3&gt;

&lt;p&gt;It's hard to get away from body electronic devices (like your phone or your laptop/PC) these days, we are always on social media and when we are programmers, we feel the need to be on our computers even to just read the email or to have it turned on. Being a programmer and having a lot of interaction with electronic devices is bad. Your job, coding, already requires you to be in front of your laptop, that energy is transmitted to your body and mind, it overcharges you (If you don't believe me, keep yourself coding one day until 12am and then try to sleep). &lt;br&gt;
In the same way you should have a routine, you should have a schedule for your electronic devices, for example: I don't use my phone while coding, or no that much, &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I only use it &lt;strong&gt;after&lt;/strong&gt; coding. &lt;/li&gt;
&lt;li&gt;I only use my laptop during weekdays, I don't code or try to not code or have some interaction of some sort with computers during the weekend.
Try to get an schedule or some sort of established-interaction time with your electronic devices, it will help you keep your life outside out of the technology world.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  The end
&lt;/h1&gt;

&lt;p&gt;These are some tips that I'm glad to share since they have helped me and they have shaped me into a better programmer, many programmers that are just getting started with programming feel like they have tons of energy, and they want to code and code and code, and this is not wrong, but it's not efficient in the long game. As I initially said, my advises are not scientifically proved so feel free to ignore them, but I highly suggest you to check them out and perhaps try them.&lt;/p&gt;

&lt;p&gt;I think everything is based on how you manage your time which is something I recall multiple times in this post.&lt;/p&gt;

&lt;p&gt;How do you feel about it? Do you have any tips? Comment below.&lt;/p&gt;

</description>
      <category>efficiency</category>
      <category>productivity</category>
      <category>career</category>
      <category>tips</category>
    </item>
    <item>
      <title>What Mandarine Framework needs to be production ready</title>
      <dc:creator>andreespirela</dc:creator>
      <pubDate>Wed, 24 Jun 2020 17:22:29 +0000</pubDate>
      <link>https://forem.com/andreespirela/what-mandarine-framework-needs-to-be-production-ready-5fpp</link>
      <guid>https://forem.com/andreespirela/what-mandarine-framework-needs-to-be-production-ready-5fpp</guid>
      <description>&lt;p&gt;During the last few days, as the creator of &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/"&gt;Mandarine Framework&lt;/a&gt;, I have not been able to stop wondering whether Mandarine is ready for production environments, that does not mean whether Mandarine has everything but whether Mandarine is reliable enough. &lt;/p&gt;

&lt;p&gt;Mandarine has grown over the past months in functionalities and stability, although the community is still fairly small, in fact, I am the only collaborator.&lt;/p&gt;

&lt;p&gt;Mandarine has an extensive built-in tools that allow you to develop complex applications (front-end &amp;amp; back-end) with important Design Patterns such as SOLID &amp;amp; Dependency Injection. Everything in Mandarine is based on the MVC pattern, SOLID, and the use of Components (Your application should be modular in order to be well-distributed). &lt;a href="https://github.com/mandarineorg/mandarinets#mandarinets-main-features"&gt;Click here to see some of the features&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With that said, I have to say: &lt;strong&gt;I do not feel comfortable with the idea of using &lt;em&gt;Mandarine&lt;/em&gt;&lt;/strong&gt; in production environments with a lot of traffic/usage.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Deno Problem
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://deno.land/"&gt;Deno&lt;/a&gt; is fairly new, it is still in its early versions (1.1.1) and it is yet to be widely used.&lt;/li&gt;
&lt;li&gt;Among other things, Deno has a lot of questions to be addressed &lt;em&gt;like&lt;/em&gt; the multiple modules issue: What if a module goes down, what if the module of a module of a module goes down. Since Deno does not have a package manager like NPM and imports are cached but they are not directly related to our application, it is hard to define or track when a module breaks another module and ends up breaking your application too as well as many other issues you can think of related to this concept.&lt;/li&gt;
&lt;li&gt;The fact that Deno is very new and its in early versions gives Mandarine a lot of impediments such as working with reliable Database modules, only if the Deno community grows to enterprise levels then Mandarine will be able to support multiple database systems.&lt;/li&gt;
&lt;li&gt;With Deno being in its early versions as well as Mandarine, it is almost impossible to determine what impact Mandarine can have on a large production environment.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Why It is not production ready
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;It needs a testing framework not only to test the core behavior but also for users to be able to test their Mandarine-powered application

&lt;ul&gt;
&lt;li&gt;As of right now, Mandarine does not have unit tests. Every module &lt;strong&gt;must&lt;/strong&gt; have unit tests.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Mandarine must have continuous integration with Github workflow.&lt;/li&gt;
&lt;li&gt;Code needs to be refactor since there are part of the code that are not located in the right places.

&lt;ul&gt;
&lt;li&gt;Part of the code needs to be cleaned.&lt;/li&gt;
&lt;li&gt;Everything in Mandarine should be a proxy or a factory in order to make testability easier.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Benchmarks must be created and added to the documentation in order to be able to measure how much changes are affecting.&lt;/li&gt;
&lt;li&gt;Mandarine &lt;strong&gt;needs&lt;/strong&gt; collaborators in order for it to grow and get impulse in both communities Javascript &amp;amp; Typescript.&lt;/li&gt;
&lt;li&gt;Evaluate how things evolve with &lt;strong&gt;Deno&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Document the life cycles of Mandarine framework engine, and perhaps make the starter implementable so the developer can override behaviors.&lt;/li&gt;
&lt;li&gt;Mandarine needs a website with the documentation and everything related to Mandarine. As of right now, &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/"&gt;Gitbook&lt;/a&gt; is being used but it turns out to not be enough.&lt;/li&gt;
&lt;li&gt;Standards need to be implemented not only for the collaborators but for everyone who uses Mandarine.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Looking for collaborators
&lt;/h1&gt;

&lt;p&gt;Mandarine is currently looking for Collaborators to help start addressing new features, fixes, but overall, the steps for Mandarine to be production ready &lt;a href="https://github.com/mandarineorg/mandarinets/issues/57"&gt;(See issue here)&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Disclaimer
&lt;/h1&gt;

&lt;p&gt;I am the creator of Mandarine Framework&lt;/p&gt;

&lt;h1&gt;
  
  
  End
&lt;/h1&gt;

&lt;p&gt;Do you have any thought? Please, I would love to know it even if I do not like it. Comment it below.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>deno</category>
      <category>mandarine</category>
      <category>framework</category>
    </item>
    <item>
      <title>Why I created Mandarine.ts Framework... and Deno.</title>
      <dc:creator>andreespirela</dc:creator>
      <pubDate>Thu, 18 Jun 2020 00:58:16 +0000</pubDate>
      <link>https://forem.com/andreespirela/why-i-created-mandarine-ts-framework-and-deno-4obe</link>
      <guid>https://forem.com/andreespirela/why-i-created-mandarine-ts-framework-and-deno-4obe</guid>
      <description>&lt;h1&gt;
  
  
  Let's talk Deno
&lt;/h1&gt;

&lt;p&gt;A few months back, I started getting involved with &lt;a href="https://deno.land"&gt;&lt;strong&gt;Deno&lt;/strong&gt;&lt;/a&gt;, the new runtime for Typescript &amp;amp; Javascript created by &lt;a href="https://medium.com/@imior/10-things-i-regret-about-node-js-ryan-dahl-2ba71ff6b4dc"&gt;Ryan Dahl&lt;/a&gt; (The creator of NodeJs). When I started trying Deno, I saw the potential it has for the whole industry, with new things coming along such as &lt;a href="https://webassembly.org/"&gt;Web Assembly&lt;/a&gt; and faster and improved versions of &lt;a href="https://en.wikipedia.org/wiki/V8_(JavaScript_engine)"&gt;V8&lt;/a&gt;, but &lt;strong&gt;most important&lt;/strong&gt;, the use &amp;amp; popularity &lt;a href="https://en.wikipedia.org/wiki/Typescript"&gt;Typescript&lt;/a&gt; is receiving due to its fantastic features &amp;amp; use cases, I could see how Deno &lt;em&gt;may&lt;/em&gt; disrupt the javascript &amp;amp; typescript industry, maybe not now, but pretty sure in the future.&lt;/p&gt;

&lt;p&gt;Deno gave me a &lt;em&gt;unique&lt;/em&gt; experience &amp;amp; feeling that as a programmer, I didn't have with Node. The fact is, Deno solves all anti-design patterns Node has as of today since it is written in Typescript, it makes your code not only flexible but also readable &amp;amp; extensible with the use of Generic classes, Decorators, Extensions, Interface &amp;amp; Implementations, and more. &lt;br&gt;
Deno also supports top-level await which is kind of a game changer since it the necessity of a &lt;strong&gt;callback hell&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Node.js&lt;/em&gt; always gave me a bit of discomfort when working with it: its package manager always stressed me out &amp;amp; the fact that I always had to "trust" the third-party libraries because Node.js &lt;strong&gt;is not secure&lt;/strong&gt; by default, this means, any library can gain access to your system without so much of trouble.&lt;br&gt;
Deno, on the other side, is secure by default, you need to pass flags to allow Deno to behave. You would &lt;code&gt;--allow-net&lt;/code&gt; to allow access to everything related to your network like socket connection for an HTTP dispatcher, or you would use &lt;code&gt;--allow-read&lt;/code&gt; to give Deno permissions to read from your file system.&lt;/p&gt;

&lt;p&gt;The reasons I mentioned &amp;amp; more made me decide that I should use Deno to build &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/"&gt;&lt;strong&gt;Mandarine.TS Framework&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Mandarine.TS Framework
&lt;/h1&gt;

&lt;p&gt;When I saw the potential of Deno and the fact that it is still in its early days, which means, it has a growing community without too much of mass adoption, I saw a big opportunity to collaborate to the open source community &amp;amp; make a enterprise framework that as the community grows, it would grow along, and possibly become the next NestJS. For that reason, I created Mandarine.TS framework.&lt;/p&gt;

&lt;p&gt;Mandarine.TS is a framework to build enterprise applications on Deno. These applications are often referred as &lt;strong&gt;Mandarine-powered applications&lt;/strong&gt;. &lt;br&gt;
Think of Mandarine.TS as a all-in-one solution for your business application: Mandarine.TS is divided in 4 modules: Data, Security, Core &amp;amp; MVC which provides different built-in functionalities and sub frameworks to meet your development standards and design patterns.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;p&gt;Mandarine.TS gives you the possibility to work with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dependency Injection&lt;/li&gt;
&lt;li&gt;Components&lt;/li&gt;
&lt;li&gt;ORM (CRUD style)&lt;/li&gt;
&lt;li&gt;Mandarine Query Language (MQL), a way to write SQL syntax without having any real SQL.

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;findByEmailAndPassword();&lt;/code&gt; = &lt;code&gt;SELECT * FROM ... WHERE email = $1 and password = $2&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Template Engine&lt;/li&gt;
&lt;li&gt;Sessions&lt;/li&gt;
&lt;li&gt;CORS&lt;/li&gt;
&lt;li&gt;Static content&lt;/li&gt;
&lt;li&gt;Resource handlers&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Mandarine &amp;amp; Javascript native code.
&lt;/h2&gt;

&lt;p&gt;Mandarine gives you the flexibility to use its technology in &lt;em&gt;native javascript&lt;/em&gt;, for example: If you want to access a mandarine-powered component (Injectable dependency) from a javascript native class without using any special code or decorator, you may do so. &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/dependency-injection/accessing-di-container#usage"&gt;Click here&lt;/a&gt; to see an example.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspiration
&lt;/h2&gt;

&lt;p&gt;Mandarine.TS was inspired in &lt;a href="https://en.wikipedia.org/wiki/Spring_Framework"&gt;Spring Boot&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Goal
&lt;/h2&gt;

&lt;p&gt;The main goal of Mandarine.TS is to solve the different enterprise problems related to their coding style &amp;amp; best practices by using the less configuration &amp;amp; more automatization as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Future
&lt;/h2&gt;

&lt;p&gt;I visualize Mandarine.TS becoming the main MVC framework in the Deno community.&lt;br&gt;
I can't deny, it's still during its early days &amp;amp; it requires a lot of new features and use cases in order to get widely used and become the main MVC framework, but the progress done as of Deno v1.1.0 has been incredible &amp;amp; it will continue improving.&lt;br&gt;
Many of the features NestJS currently offers are yet to come along with unique features in Mandarine, but as everything in development, it requires time &amp;amp; users using it.&lt;/p&gt;

&lt;h1&gt;
  
  
  Should I use Deno?
&lt;/h1&gt;

&lt;p&gt;This is one questions that can be found as controversial. Many people are already on what I would call "The Deno hype" while others are skeptical. I'm personally in the middle of both sides. If you are building an enterprise application that will be used by thousands of people, I would highly recommend you to go with Node.js as it has more support than Deno and more modules that will save you time, code and worries. However, if you are building an enterprise application that will be used only by the people that work there, or a general application that is not expected to grow so quickly, then Deno is your way to go and catch-up with the newest technologies in the market. &lt;/p&gt;

&lt;p&gt;As mentioned before, Deno is still in its early days. You can already build complex applications that can even be used in Production, but for more stability, we will have to wait two important things from the Deno community&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A typescript compiler fully written in Rust&lt;/li&gt;
&lt;li&gt;A HTTP module fully written in Rust.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Should I use Mandarine.TS Framework?
&lt;/h1&gt;

&lt;p&gt;As well as Deno, Mandarine.TS framework is still in its early days, it has a lot to offer but it also has a lot of features missing. If you are working on creating an application for a start-up, Mandarine.TS is the way to go. However, if your application is more enterprise-like or enterprise-used, then there are a couple things to consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is missing features&lt;/li&gt;
&lt;li&gt;Expect breaking changes as early versions roll out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mandarine.TS can already cover a lot of requirements for any type of application, but it needs work &amp;amp; it needs to be improved to reach its goal: A all-in-one solution for enterprises which makes me recommend Mandarine for small applications or in-house applications in your company.&lt;/p&gt;

&lt;h1&gt;
  
  
  Thoughts
&lt;/h1&gt;

&lt;p&gt;1) I personally don't think Deno will replace NodeJS, mainly because NodeJS is used across &lt;strong&gt;millions&lt;/strong&gt; of companies which affect &lt;strong&gt;billion of people&lt;/strong&gt;. I do think Deno will get widely used in the next 4-5 years for the new start-ups and projects that existing companies will have since it solves many of the uncomfortable things of Node. In a nutshell, I see Deno being used for new projects &amp;amp; new requirements rather than an option to migrate a NodeJs project.&lt;/p&gt;

&lt;p&gt;2) The future of Mandarine.TS is very very interesting, the amount of features &amp;amp; achievements in a so short period of time makes Mandarine.TS framework something to look at, it still needs a community, more collaborators &amp;amp; enterprise usage. As of right now, Mandarine.TS is a solution for small projects or big projects used by a small amount of people, however, it is expected to have major changes this year 2020 that would change the concept of Mandarine.TS and would make it a enterprise-level solution.&lt;/p&gt;

&lt;h1&gt;
  
  
  The end
&lt;/h1&gt;

&lt;p&gt;We have analyzed what Deno is &amp;amp; what Mandarine.Ts framework is, we have seen the possible futures of both &amp;amp; the options we have.&lt;/p&gt;

&lt;p&gt;Do you have any thought? I would love to hear it, even if I don't like it or agree. Leave a comment below!.&lt;/p&gt;

</description>
      <category>mandarinets</category>
      <category>typescript</category>
      <category>deno</category>
      <category>framework</category>
    </item>
    <item>
      <title>Deno API + Postgres: without SQL</title>
      <dc:creator>andreespirela</dc:creator>
      <pubDate>Tue, 09 Jun 2020 22:49:13 +0000</pubDate>
      <link>https://forem.com/andreespirela/deno-api-postgres-without-sql-16hk</link>
      <guid>https://forem.com/andreespirela/deno-api-postgres-without-sql-16hk</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Throughout my years of programming, I have seen many applications that combine the database layer with the business logic of the app. In one way or the other, some ORM's fail to disperse the concepts of application layers &amp;amp; make your app not &lt;a href="https://en.wikipedia.org/wiki/Single-responsibility_principle"&gt;singly-responsible&lt;/a&gt;. When I was first getting into programming, I did this too but after learning &amp;amp; learning, it started seeming like an odd thing to do.&lt;br&gt;
In this article, we will be exploring how to create a simple API that will run on Deno and will use Postgres as its database, but the interesting thing is that we &lt;strong&gt;will not use&lt;/strong&gt; &lt;em&gt;SQL&lt;/em&gt; whatsoever, thus, we won't mix the business logic of our application with the database layer.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Deno?
&lt;/h2&gt;

&lt;p&gt;According to the &lt;a href="https://deno.land"&gt;Deno website&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.&lt;br&gt;
It was first created by Ryan Dahl, the same creator of Node.JS.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  What we'll need
&lt;/h2&gt;

&lt;p&gt;We will be exploring the following&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deno&lt;/li&gt;
&lt;li&gt;Mandarine.TS framework (A framework to build applications, specially web apps)&lt;/li&gt;
&lt;li&gt;Mandarine.TS ORM&lt;/li&gt;
&lt;li&gt;PostgreSQL&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Goals
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create a simple API that uses Postgres &lt;strong&gt;without writing SQL&lt;/strong&gt; on our application.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Getting Started
&lt;/h1&gt;
&lt;h3&gt;
  
  
  Step 1: tsconfig.json
&lt;/h3&gt;

&lt;p&gt;Mandarine requires us to use a &lt;code&gt;tsconfig.json&lt;/code&gt; in order for the typescript compiler to work properly.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;tsconfig.json&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"strict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"noImplicitAny"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"noImplicitThis"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"alwaysStrict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"strictNullChecks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"strictFunctionTypes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"strictPropertyInitialization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"experimentalDecorators"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"emitDecoratorMetadata"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"allowUmdGlobalAccess"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Database configuration
&lt;/h3&gt;

&lt;p&gt;In order for Mandarine's internal ORM to work, we will need to establish our connection configuration inside &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/properties#setting-your-own-properties"&gt;Mandarine's property file&lt;/a&gt;.&lt;br&gt;
For this, we will create a file called &lt;code&gt;properties.json&lt;/code&gt; under &lt;code&gt;/src/main/resources&lt;/code&gt; (&lt;strong&gt;your-project&lt;/strong&gt;/src/main/resources/properties.json)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;properties.json&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"mandarine"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"dataSource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"dialect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"postgresql"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"host"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"localhost"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5432&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"postgres"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"password"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"database"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now you just have to put the your connection information.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Creating our Model.
&lt;/h3&gt;

&lt;p&gt;A model is an object that represents an entity (table) in our database. The properties are used to represent columns.&lt;br&gt;
To create our model, we will create a folder called "&lt;strong&gt;database&lt;/strong&gt;" (which we will divide into two folders: &lt;em&gt;models&lt;/em&gt; and &lt;em&gt;repositories&lt;/em&gt;). Inside the &lt;em&gt;models&lt;/em&gt; folder, we will locate our model called: &lt;strong&gt;booksModel.ts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;booksModel.ts&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;Table&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/mandarinets/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="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;IBook&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&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="nd"&gt;Table&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;public&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;books&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;class&lt;/span&gt; &lt;span class="nx"&gt;BooksModel&lt;/span&gt; &lt;span class="kr"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;IBook&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 the above example, we are importing the decorator &lt;code&gt;Table&lt;/code&gt; from Mandarine.TS framework repository &amp;amp; we are decorating our class BooksModel with it, basically &lt;em&gt;telling Mandarine&lt;/em&gt; that this class is an entity. &lt;strong&gt;Note&lt;/strong&gt; that if you do not specify the property &lt;code&gt;name&lt;/code&gt; in the decorator then Mandarine will take the name of the class as it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Adding columns to our Model.
&lt;/h3&gt;

&lt;p&gt;Now that we have created our model, it's time to add some columns.&lt;/p&gt;

&lt;p&gt;Our class BooksModel (&lt;em&gt;booksModel.ts&lt;/em&gt;) will look like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;Table&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;GeneratedValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Column&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/mandarinets/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="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;IBook&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&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="nd"&gt;Table&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;public&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;books&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;class&lt;/span&gt; &lt;span class="nx"&gt;BooksModel&lt;/span&gt; &lt;span class="kr"&gt;implements&lt;/span&gt; &lt;span class="nx"&gt;IBook&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Id&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;GeneratedValue&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;SEQUENCE&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="kr"&gt;public&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;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&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 the code above, we are indicating that we will have 3 columns: &lt;em&gt;id&lt;/em&gt;, &lt;em&gt;name&lt;/em&gt;, and &lt;em&gt;author&lt;/em&gt; (We are decorating them with &lt;code&gt;@Column&lt;/code&gt;), but we are also indicating that the column &lt;code&gt;id&lt;/code&gt; will be a primary key since we are decorating it with &lt;code&gt;@Id&lt;/code&gt; &amp;amp; we are also indicating that it will be auto-increment (&lt;code&gt;@GeneratedValue&lt;/code&gt;). &lt;strong&gt;Note&lt;/strong&gt; that GeneratedValue must always be used if we want to insert data directly from Mandarine's ORM.&lt;br&gt;
There is a lot of documentation on how to use those three decorators. &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-data/orm/models"&gt;Click here to see the official documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; that you &lt;strong&gt;do not&lt;/strong&gt; have to create the table manually. Instead, Mandarine will create this table (if it doesn't exist) called &lt;code&gt;books&lt;/code&gt; at mandarine compile time so you do not have to worry about handling database operations at all.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 5: Creating our SQL-free Repository
&lt;/h3&gt;

&lt;p&gt;A repository is a class that handles your database queries. Unlike many ORM providers, Mandarine.TS framework gives us one of its most amazing features: &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-data/mandarine-query-language"&gt;&lt;strong&gt;MQL&lt;/strong&gt; (&lt;em&gt;Mandarine Query Language&lt;/em&gt;)&lt;/a&gt;, which is the equivalent to the CRUD interface in Java for example. &lt;em&gt;Mandarine-powered&lt;/em&gt; repositories are extremely easy to use and practical as they save us a lot of time and code.&lt;br&gt;
We will create our repository under the folder &lt;em&gt;database/repositories&lt;/em&gt; that we created during &lt;strong&gt;Step 3&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;booksRepository.ts&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;Repository&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;MandarineRepository&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/mandarinets/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;BooksModel&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;../models/booksModel.ts&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="nd"&gt;Repository&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;BooksRepository&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;MandarineRepository&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;BooksModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;BooksModel&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the code above, we have created the an abstract class &lt;code&gt;BooksRepository&lt;/code&gt; and we have decorated it with &lt;code&gt;@Repository&lt;/code&gt;, this way, we will let Mandarine know that this class should be considered a Mandarine-powered repository. &lt;strong&gt;Note&lt;/strong&gt; that for a class to be a &lt;em&gt;Mandarine-powered repository&lt;/em&gt;, we &lt;strong&gt;must&lt;/strong&gt; extend it to &lt;a href="https://doc.deno.land/https/raw.githubusercontent.com/mandarineorg/mandarinets/master/orm-core/repository/mandarineRepository.ts#MandarineRepository"&gt;MandarineRepository&lt;/a&gt; which is a generic class that will take our model. After extending it, we need to call &lt;code&gt;super&lt;/code&gt; from our repository's constructor. &lt;code&gt;super&lt;/code&gt; will take one argument which is the class representation of our model (without being initialized, just the class)&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Adding methods to our repository
&lt;/h3&gt;

&lt;p&gt;Now that we have created our repository, we will be adding methods that we will use later to request our database. This is where the fun begins because these methods we will write will be empty methods, without anything inside but they will actually bring or send information to our database. Let's see..&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Repository&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;BooksRepository&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;MandarineRepository&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;BooksModel&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;BooksModel&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;findById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;findByAuthor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;findByName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;findByIdAndName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the example above, we have added 4 new methods to our repository: &lt;code&gt;findById&lt;/code&gt;, &lt;code&gt;findByAuthor&lt;/code&gt;, &lt;code&gt;findByName&lt;/code&gt;, &lt;code&gt;findByIdAndName&lt;/code&gt;. &lt;br&gt;
&lt;strong&gt;Note&lt;/strong&gt; our columns in the model have to match the name in the name of our methods, we can't just write whatever (This should be self-explanatory but I don't mind taking the time to remind about it).&lt;br&gt;
These methods will then be processed by &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-data/mandarine-query-language"&gt;MQL&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 7: Creating our Controller
&lt;/h3&gt;

&lt;p&gt;In this step, we will be creating our API controller which we will request to interact with our database. We will be injecting our repository in this controller but &lt;strong&gt;note&lt;/strong&gt;, for production environments, I would highly recommend to have a service where your repository will be injected, and the service class will be the one to interact with your controller, although, since this is a tutorial, I will not get into that to not make it harder.&lt;/p&gt;

&lt;p&gt;We will create a folder in the root of our project called "controllers" and in that folder we will create the following file&lt;/p&gt;

&lt;p&gt;&lt;em&gt;booksController.ts&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;Controller&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/mandarinets/mod.ts&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="nd"&gt;Controller&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api&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;class&lt;/span&gt; &lt;span class="nx"&gt;BooksController&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 the above example, we have created our controller which will have a base route which is &lt;code&gt;/api&lt;/code&gt;, this means, all the endpoints that belong to this controller will be part of the URL &lt;code&gt;/api&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 8: Injecting our repository in our controller
&lt;/h3&gt;

&lt;p&gt;Now that we have created our controller, it's time to inject our repository by using Mandarine's Dependency Injection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;Controller&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/mandarinets/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;BooksRepository&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;../database/repositories/booksRepository.ts&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="nd"&gt;Controller&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api&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;class&lt;/span&gt; &lt;span class="nx"&gt;BooksController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;booksRepository&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BooksRepository&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;While it is true that we could use the &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/dependency-injection#the-inject-decorator"&gt;&lt;code&gt;@Inject&lt;/code&gt; decorator&lt;/a&gt;, the best practice is to do injections in the constructor of our component.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 9: Creating endpoints
&lt;/h3&gt;

&lt;p&gt;In this step, we will be adding the endpoints we will request to interact with our database.&lt;/p&gt;

&lt;p&gt;Our &lt;em&gt;booksController.ts&lt;/em&gt; will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;Controller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;RequestBody&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="nx"&gt;RouteParam&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;QueryParam&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/mandarinets/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;BooksRepository&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;../database/repositories/booksRepository.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;IBook&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;BooksModel&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;../database/models/booksModel.ts&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="nd"&gt;Controller&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api&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;class&lt;/span&gt; &lt;span class="nx"&gt;BooksController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;booksRepository&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BooksRepository&lt;/span&gt;&lt;span class="p"&gt;){}&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/add-book&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;addBook&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nd"&gt;RequestBody&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;bookToAdd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IBook&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newBook&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BooksModel&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;BooksModel&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nx"&gt;newBook&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;author&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;bookToAdd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;newBook&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;bookToAdd&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="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;booksRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newBook&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="na"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;New book have been added&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="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/get-book/:id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;getBookById&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nd"&gt;RouteParam&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&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="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;booksRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&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="nd"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/:author/books&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;getBooksByAuthor&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nd"&gt;RouteParam&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&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="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;booksRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findByAuthor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;author&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="nd"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/search&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;getBooksByIdAndName&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nd"&gt;QueryParam&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;QueryParam&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;string&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="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;booksRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findByIdAndName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&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="p"&gt;}&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/all-books&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nx"&gt;getAllBooks&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="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;booksRepository&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findAll&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I know, it can seem like a lot of code so let me explain some of it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;addBook&lt;/code&gt;: Add a book to our database using &lt;code&gt;repository.save&lt;/code&gt;, the method &lt;code&gt;save&lt;/code&gt; in our repository is a mandarine reserved keyword for repositories, and it will resolve the insertion of a new row.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;getAllBooks&lt;/code&gt;: List all the books that we have in our database by using &lt;code&gt;repository.findAll&lt;/code&gt;. &lt;code&gt;findAll&lt;/code&gt; is another Mandarine reserved keyword for repositories, it is responsible for bringing all the rows of that specific table.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 10: Creating our single-entry point file.
&lt;/h3&gt;

&lt;p&gt;The single entry-point file is a file where we will import all our components in order for Mandarine &amp;amp; Deno to compile them properly. You can read more about this in Mandarine's official Documentation &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/core-initialization#single-entry-point-file"&gt;(Click here)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will create this file in the root of our project and we'll call it &lt;strong&gt;entry-point.ts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;app.ts&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;BooksController&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;./controllers/booksController.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;BooksRepository&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;./database/repositories/booksRepository.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;MandarineCore&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/mandarinets/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;controllers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;BooksController&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;repositories&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;BooksRepository&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MandarineCore&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;MVC&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 10: Running our app.
&lt;/h3&gt;

&lt;p&gt;Now to run our app, we will run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;deno run &lt;span class="nt"&gt;--config&lt;/span&gt; tsconfig.json &lt;span class="nt"&gt;--allow-net&lt;/span&gt; &lt;span class="nt"&gt;--allow-read&lt;/span&gt; entry-point.ts
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 11: Interacting.
&lt;/h3&gt;

&lt;p&gt;As we coded before, we have an endpoint for adding books which is a POST-type endpoint. Now we will send some &lt;strong&gt;JSON&lt;/strong&gt; data to it.&lt;br&gt;
I personally use postman, but you can use any REST client you'd like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nf"&gt;POST&lt;/span&gt; &lt;span class="nn"&gt;/api/add-book&lt;/span&gt; &lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;localhost:8080&lt;/span&gt;
&lt;span class="na"&gt;Content-Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;application/json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The Diary Of a Young Girl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Anne Frank"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And let's add one more book&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nf"&gt;POST&lt;/span&gt; &lt;span class="nn"&gt;/api/add-book&lt;/span&gt; &lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;localhost:8080&lt;/span&gt;
&lt;span class="na"&gt;Content-Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;application/json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Sapiens: A Brief History of Humankind"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Yuval Noah Harari"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Getting a book by its ID
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;/get-book/:id&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Now, let's try our endpoint &lt;code&gt;/get-book/:id&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nf"&gt;GET&lt;/span&gt; &lt;span class="nn"&gt;/api/get-book/1&lt;/span&gt; &lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;localhost:8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and to that request, we are getting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The Diary Of a Young Girl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Anne Frank"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Getting books by its author
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;/:author/books&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Now, let's try our endpoint &lt;code&gt;/:author/books&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /api/Yuval Noah Harari/books HTTP/1.1
Host: localhost:8080
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;which will make us get&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Sapiens: A Brief History of Humankind"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Yuval Noah Harari"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Searching a book by name &amp;amp; id
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;/search&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Our first book (1) is &lt;code&gt;The Diary Of a Young Girl&lt;/code&gt;&lt;br&gt;
Now let's try to find it by using this endpoint&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /api/search?id=1&amp;amp;name=The Diary Of a Young Girl HTTP/1.1
Host: localhost:8080
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;which will return&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
    {
        "id": 1,
        "name": "The Diary Of a Young Girl",
        "author": "Anne Frank"
    }
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Getting all books in our table.
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;/all-books&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Finally, let's test our endpoint which is responsible for returning all the books we have added.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nf"&gt;GET&lt;/span&gt; &lt;span class="nn"&gt;/api/all-books&lt;/span&gt; &lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;localhost:8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;which will return the following array&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The Diary Of a Young Girl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Anne Frank"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Sapiens: A Brief History of Humankind"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Yuval Noah Harari"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  There is more
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Mandarine's ORM has reserved methods such as &lt;code&gt;findAll&lt;/code&gt; or &lt;code&gt;save&lt;/code&gt; that will save you a lot of code already. But there is more to it. Mandarine has &lt;code&gt;countAll&lt;/code&gt; (returns the amount of rows in the table), &lt;code&gt;deleteAll&lt;/code&gt; (deletes all rows) and the possibility to write &lt;code&gt;existsBy...&lt;/code&gt; which would return a boolean value after evaluating if a row exists =&amp;gt; &lt;code&gt;existsById&lt;/code&gt; would be a good example of this.&lt;/li&gt;
&lt;li&gt;If you would like to learn more about Mandarine.TS framework &amp;amp; specially Mandarine.TS ORM, don't hesitate to visit its &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/"&gt;official documentation&lt;/a&gt; and follow me.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;h2&gt;
  
  
  What we did:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;We created an API with Deno, Mandarine &amp;amp; Postgres&lt;/li&gt;
&lt;li&gt;We used Mandarine.TS framework ORM&lt;/li&gt;
&lt;li&gt;We added &amp;amp; requested data from our database &lt;strong&gt;without&lt;/strong&gt; having to write any &lt;strong&gt;SQL&lt;/strong&gt; &lt;em&gt;whatsoever&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;We created models, repositories &amp;amp; controllers
## Why Mandarine.TS?&lt;/li&gt;
&lt;li&gt;As we saw in this article and past articles I have written, Mandarine.TS offers a lot of built-in solutions that will save us a lot of code and will allow us to work in a more enterprise way as well as making our code simple &amp;amp; readable.&lt;/li&gt;
&lt;li&gt;Mandarine.TS is decorator driven which gives us a lot of flexibility on how to write our code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Note
&lt;/h1&gt;

&lt;p&gt;The intention of this article is to show how to build an API with Deno. The examples shown are simple examples that are not meant to be used in production environments.&lt;/p&gt;

&lt;h1&gt;
  
  
  Disclaimer
&lt;/h1&gt;

&lt;p&gt;I am the creator of Mandarine.TS Framework.&lt;/p&gt;

&lt;h1&gt;
  
  
  The end
&lt;/h1&gt;

&lt;p&gt;Get the full source code &lt;a href="https://github.com/andreespirela/deno-tutorials/tree/master/database-books-api"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do you have any question or something to say? If so, please leave a comment. If you like this article, please tweet it!&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>deno</category>
      <category>mvc</category>
      <category>postgres</category>
    </item>
    <item>
      <title>Writing an API with Deno</title>
      <dc:creator>andreespirela</dc:creator>
      <pubDate>Mon, 08 Jun 2020 03:21:59 +0000</pubDate>
      <link>https://forem.com/andreespirela/writing-an-api-with-deno-106p</link>
      <guid>https://forem.com/andreespirela/writing-an-api-with-deno-106p</guid>
      <description>&lt;p&gt;In this post, we will be developing a small API system using &lt;strong&gt;Deno&lt;/strong&gt; (A runtime for Javascript &amp;amp; Typescript developed by Ryan Dahl, Node.JS creator). &lt;/p&gt;

&lt;p&gt;For our API system we will be using &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/"&gt;Mandarine.TS framework&lt;/a&gt;. This framework will help us code &amp;amp; save a lot of time in our design as it has built-in solutions such as Dependency Injection, HTTP Handlers &amp;amp; Routes, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Goals
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create an API which manages &lt;em&gt;books&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Provide GET &amp;amp; POST Routes&lt;/li&gt;
&lt;li&gt;Use Mandarine.TS to get you involved with this framework and why it can be important when using Deno for web applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Let's get started.
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Concepts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Services: Classes Where our business logic is.
&lt;/li&gt;
&lt;li&gt;Controllers: Classes responsible for handling HTTP requests as well as creating the routes for it.&lt;/li&gt;
&lt;li&gt;Mandarine.ts/Mandarine: A Typescript decorator-driven web framework for Deno.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Now, coding.
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Step 1
&lt;/h4&gt;

&lt;p&gt;We will be creating a &lt;code&gt;tsconfig.json&lt;/code&gt; file in the root of our project. Mandarine.TS framework requires a &lt;code&gt;tsconfig.json&lt;/code&gt; in order to work properly.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;tsconfig.json&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"strict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"noImplicitAny"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"noImplicitThis"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"alwaysStrict"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"strictNullChecks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"strictFunctionTypes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"strictPropertyInitialization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"experimentalDecorators"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"emitDecoratorMetadata"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"allowUmdGlobalAccess"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 2
&lt;/h4&gt;

&lt;p&gt;We will be creating a typescript file and we will call it &lt;code&gt;books-service.ts&lt;/code&gt;. This file will contain the functioning of our API that we will later be using in our &lt;em&gt;Controller&lt;/em&gt;. We will locate this file inside a folder called &lt;strong&gt;services&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;books-service.ts&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;Service&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/mandarinets/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;let&lt;/span&gt; &lt;span class="nx"&gt;books&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;IBook&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;IBook&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;IBook&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&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="nd"&gt;Service&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;class&lt;/span&gt; &lt;span class="nx"&gt;BooksService&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 code above, we are importing from the repository of Mandarine.TS framework the decorator &lt;code&gt;@Service()&lt;/code&gt; which will decorate our class &lt;code&gt;BooksService&lt;/code&gt;, this way, Mandarine can interpret this as a &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/components"&gt;Mandarine-powered component&lt;/a&gt;. We have also declared a variable called &lt;code&gt;books&lt;/code&gt; which we will be using to add &amp;amp; get books from, and we have created an interface &lt;code&gt;IBook&lt;/code&gt;, which is simply the structure of the book item.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 3
&lt;/h4&gt;

&lt;p&gt;Now that we have our service class decorated with &lt;code&gt;@Service()&lt;/code&gt;, we will be adding some logic to it, we will create 4 methods: &lt;code&gt;addBook&lt;/code&gt;, &lt;code&gt;getBookById&lt;/code&gt;, &lt;code&gt;getBookByName&lt;/code&gt;, &lt;code&gt;getAllBooks&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Service&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;class&lt;/span&gt; &lt;span class="nx"&gt;BooksService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;addBook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&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;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&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="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;books&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;book&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;books&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
                &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;name&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="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;author&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="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;getBookById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;IBook&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;books&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;book&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;getBookByName&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;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;IBook&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;books&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;book&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;book&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;getAllBooks&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;IBook&lt;/span&gt;&lt;span class="o"&gt;&amp;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;books&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;addBook&lt;/code&gt;: Adds a book only when the &lt;strong&gt;id&lt;/strong&gt; or the &lt;strong&gt;name&lt;/strong&gt; are available.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;getBookById&lt;/code&gt;: Look up a book in the array that matches with our provided id.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;getBookByName&lt;/code&gt;: Look up a book in the array that matches with our provided book name.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;getAllBooks&lt;/code&gt;: Returns all the books that have been added.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 4
&lt;/h4&gt;

&lt;p&gt;In this step, we will be creating our controller. For this, we will create a new folder in the root of our project called &lt;strong&gt;controllers&lt;/strong&gt;, and in this folder, we will locate our &lt;strong&gt;books-controller.ts&lt;/strong&gt; which will contain our controller class.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;books-controller.ts&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;Controller&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/mandarinets/mod.ts&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="nd"&gt;Controller&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api&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;class&lt;/span&gt; &lt;span class="nx"&gt;BooksController&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 the code above, we have declared our controller by using the decorator &lt;code&gt;@Controller&lt;/code&gt; which will inform Mandarine that this is a class that must be considered a controller &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/components/controller"&gt;(See official documentation here)&lt;/a&gt;. As you can see, we are passing a parameter to our decorator with the value &lt;code&gt;/api&lt;/code&gt;, this means, all the routes inside our controller will have to start with &lt;code&gt;/api&lt;/code&gt; when requesting them.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 5
&lt;/h4&gt;

&lt;p&gt;Now that we have declared our controller, we will &lt;strong&gt;inject&lt;/strong&gt; our Service. This is done by importing our Service &amp;amp; putting it in the constructor of our controller.&lt;br&gt;&lt;br&gt;
Our code will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;Controller&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/mandarinets/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;BooksService&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;../services/books-service.ts&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="nd"&gt;Controller&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api&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;class&lt;/span&gt; &lt;span class="nx"&gt;BooksController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;booksService&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BooksService&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;By injecting our service, Mandarine will resolve all its dependencies (if it has) and will make it available for us to use in our controller component without needing to manually initialize it. &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/dependency-injection"&gt;(See more documentation about this here)&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 6
&lt;/h4&gt;

&lt;p&gt;Now that we have our controller &amp;amp; we have also injected our book service (&lt;code&gt;BooksService&lt;/code&gt;), we will proceed to create 3 endpoints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/api/books/add-sample&lt;/code&gt;: It will add default books to our books array when requesting it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/api/books/getAll&lt;/code&gt;: It will return all the books that have been added.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/api/books/get&lt;/code&gt;: It will get a book from the array by filtering by ID or book name.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our controller will look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;Controller&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="nx"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;QueryParam&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/mandarinets/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;BooksService&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;../services/books-service.ts&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="nd"&gt;Controller&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api&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;class&lt;/span&gt; &lt;span class="nx"&gt;BooksController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;booksService&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BooksService&lt;/span&gt;&lt;span class="p"&gt;){}&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/books/add-sample&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;addSampleBooksHandler&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;booksService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addBook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;The Diary Of a Young Girl&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Anne Frank&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;booksService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addBook&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sapiens: A Brief History of Humankind&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Yuval Noah Harari&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Success&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="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/books/getAll&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;getAllBooks&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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;booksService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getAllBooks&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="nd"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/books/get&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;getBook&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nd"&gt;QueryParam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;search&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;typeOfSearch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;QueryParam&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;string&lt;/span&gt;&lt;span class="p"&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;typeOfSearch&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;id&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="c1"&gt;// We use &amp;lt;any&amp;gt; so the compiler doesn't complain about using a possible string for a number parameter in getBookById&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;booksService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getBookById&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;any&lt;/span&gt;&lt;span class="o"&gt;&amp;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="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;booksService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getBookByName&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="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;&lt;strong&gt;Note&lt;/strong&gt; that we are importing 3 new items: &lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;POST&lt;/code&gt;, and &lt;code&gt;QueryParam&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;GET&lt;/code&gt;: Will create a GET route. It takes one parameter which is the route to create.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;POST&lt;/code&gt;: Will create a GET route. It takes one parameter which is the route to create.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;QueryParam&lt;/code&gt;: It is a &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-mvc/controllers/http-handlers#http-parameter-decorators"&gt;HTTP Parameter Decorator&lt;/a&gt; which will be responsible for injecting the values from the query parameters of the request into our HTTP handler. Refer to the link for a deeper explanation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 7
&lt;/h4&gt;

&lt;p&gt;Now that we have our service &amp;amp; controller for our books, we will proceed to create the entry point file. If you have got to this step, congratulations, this step is extremely easy &amp;amp; straight forward as we are just importing our classes to a common place.&lt;br&gt;
This entry point file we will create is the file we will run with &lt;strong&gt;Deno&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will locate this file in the root of our project and we will call it &lt;strong&gt;entry-point.ts&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;entry-point.ts&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;MandarineCore&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/mandarinets/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;BooksService&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;./services/books-service.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;BooksController&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;./controllers/books-controller.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;services&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;BooksService&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;controllers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;BooksController&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MandarineCore&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;MVC&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the code above, we are basically locating our components in just one place.&lt;br&gt;
&lt;code&gt;MandarineCore&lt;/code&gt; is possibly the most important part for your code as it handles the engine of Mandarine Framework. This engine will resolve our dependencies &amp;amp; run our website. &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/core-initialization"&gt;(See more here)&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Step 8: Running our Mandarine-powered API.
&lt;/h4&gt;

&lt;p&gt;To run our web application, we will run the following command in the root of our project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;deno run &lt;span class="nt"&gt;--config&lt;/span&gt; tsconfig.json &lt;span class="nt"&gt;--allow-read&lt;/span&gt; &lt;span class="nt"&gt;--allow-net&lt;/span&gt; entry-point.ts
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After running that, we should be seeing our engine started which would mean we are ready to request our API.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 9: Requesting our API
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;/api/books/add-sample&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nf"&gt;POST&lt;/span&gt; &lt;span class="nn"&gt;/api/books/add-sample&lt;/span&gt; &lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;localhost:8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;which will return &lt;code&gt;Success&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/api/books/getAll&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nf"&gt;GET&lt;/span&gt; &lt;span class="nn"&gt;/api/books/getAll&lt;/span&gt; &lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;localhost:8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;which will return&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The Diary Of a Young Girl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Anne Frank"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Sapiens: A Brief History of Humankind"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Yuval Noah Harari"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;/api/books/get?search=id&amp;amp;data=2&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nf"&gt;GET&lt;/span&gt; &lt;span class="nn"&gt;/api/books/get?search=id&amp;amp;data=2&lt;/span&gt; &lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;localhost:8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;which will return&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The Diary Of a Young Girl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Anne Frank"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What we did&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We created an API using Deno.&lt;/li&gt;
&lt;li&gt;We created an API using &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts"&gt;Mandarine.TS&lt;/a&gt; as our framework.&lt;/li&gt;
&lt;li&gt;We interacted with &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/dependency-injection"&gt;Dependency Injection&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;We worked with nested routes (Base route in controller to its children)&lt;/li&gt;
&lt;li&gt;We tested our endpoints.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Mandarine.ts was used as the web framework&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mandarine saves us a lot of code &amp;amp; functionalities to build any type of web application. This time we used it for an API and in a few lines of code we did a lot with it (Services, Controllers, Handlers, Dependency Injection). &lt;/li&gt;
&lt;li&gt;Mandarine is decorator-driven, which means, it uses a lot of decorators to interpret functionalities which makes our code more readable and shorter.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Note
&lt;/h2&gt;

&lt;p&gt;The intention of this article is to show how to build an API with &lt;strong&gt;Deno&lt;/strong&gt;. The examples shown are simple examples that are not meant to be used in production environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;I am the creator of Mandarine.TS Framework.&lt;/p&gt;

&lt;h2&gt;
  
  
  The end
&lt;/h2&gt;

&lt;p&gt;Get the full source code &lt;a href="https://github.com/andreespirela/deno-tutorials/tree/master/simple-books-api"&gt;by clicking here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Do you have any question or something to say? If so, please leave a comment. If you like this article, please tweet it!&lt;/p&gt;

</description>
      <category>deno</category>
      <category>typescript</category>
      <category>api</category>
      <category>mandarinets</category>
    </item>
    <item>
      <title>Mandarine.TS, the next ExpressJS? </title>
      <dc:creator>andreespirela</dc:creator>
      <pubDate>Fri, 05 Jun 2020 15:21:33 +0000</pubDate>
      <link>https://forem.com/andreespirela/mandarine-ts-the-next-expressjs-3j7a</link>
      <guid>https://forem.com/andreespirela/mandarine-ts-the-next-expressjs-3j7a</guid>
      <description>&lt;h1&gt;
  
  
  What is Mandarine.TS?
&lt;/h1&gt;

&lt;p&gt;Mandarine.TS is a framework that allows you to develop applications, mainly web-applications. It is written in Typescript and runs on &lt;a href="https://deno.land"&gt;Deno&lt;/a&gt; (A Javascript &amp;amp; Typescript runtime created by Ryan Dahl, inventor of Node.JS) and it recently released its version 1.0.0.  &lt;/p&gt;

&lt;p&gt;Mandarine is divided into 4 modules: &lt;strong&gt;Core&lt;/strong&gt;, &lt;strong&gt;Data&lt;/strong&gt;, &lt;strong&gt;Security&lt;/strong&gt; &amp;amp; &lt;strong&gt;MVC&lt;/strong&gt; which essentially give you tools to create Mandarine-powered applications. &lt;/p&gt;

&lt;p&gt;From &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/"&gt;the official documentation&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Under its umbrella, Mandarine.TS has 4 modules: Core, Data, Security and MVC, these modules will offer you the requirements to build a Mandarine-powered application. However, the most common module is Mandarine MVC, since it combines all the concepts from its different cores into one, in order to make the creation of complex web-applications (front-end &amp;amp; back-end) easy, reliable, and following design patterns &amp;amp; principles such as SOLID, making your application sustainable &amp;amp; readable across developers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Mandarine offers you in its 4 different modules the use of: Dependency Injection, Components, Routes, HTTP Handlers, Session middleware, built-in ORM, Template Engine, and more.&lt;/p&gt;

&lt;h1&gt;
  
  
  The real question. Is Mandarine the next ExpressJS?
&lt;/h1&gt;

&lt;p&gt;Mandarine can be considered fundamentally different when it comes to comparing it to ExpressJS. They can perform the same tasks but they are not the same when it comes to using it and writing it.&lt;/p&gt;

&lt;p&gt;Differences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mandarine.TS is known for being &lt;strong&gt;decorator-driven&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Mandarine.TS is not only for web applications but for any kind of typescript application that runs on Deno.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Decorator-driven
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Example I
&lt;/h3&gt;

&lt;p&gt;Almost everything in Mandarine needs a decorator, this will make your code readable and easy to write.&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;Controller&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="nx"&gt;MandarineCore&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/mandarinets/mod.ts&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="nd"&gt;Controller&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api&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;class&lt;/span&gt; &lt;span class="nx"&gt;Boo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/hello-world&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;helloWorld&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World&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="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MandarineCore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MVC&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# request =&amp;gt; http://localhost:4444/api/hello-world =&amp;gt; Hello World
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Example II
&lt;/h3&gt;



&lt;div class="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;Controller&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="nx"&gt;RouteParam&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;QueryParam&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;MandarineCore&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/mandarinets/mod.ts&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="nd"&gt;Controller&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;TestController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;GET&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/say-hi/:name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kr"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;helloWorld&lt;/span&gt;&lt;span class="p"&gt;(@&lt;/span&gt;&lt;span class="nd"&gt;RouteParam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;personsName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;QueryParam&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="nx"&gt;lastname&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;personsName&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;lastname&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, welcome.`&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="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;MandarineCore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MVC&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# request =&amp;gt; http://localhost:4444/say-hi/Bill?lastname=Gates =&amp;gt; Hello Bill Gates, welcome.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Not only for web-apps.
&lt;/h2&gt;

&lt;p&gt;Although the concept of "Mandarine Native" is really in its early days as Mandarine.TS 1.0.0 was only released yesterday, The objective of Mandarine is to create Mandarine-powered applications that let a development environment use built-in solutions such as DI &amp;amp; Components without having to compile it into a web app. Some of this concept is already possible, for example, you can use Mandarine's DI framework in a javascript/typescript native class &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/dependency-injection/accessing-di-container#usage"&gt;(See example here)&lt;/a&gt; but this concept is still being developed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mandarine.TS vs ExpressJS
&lt;/h2&gt;

&lt;p&gt;ExpressJS has been out there for a decade now, this makes it more reliable in terms of community size &amp;amp; it runs on Node, a runtime that has been out there for a decade and a year now. This may make ExpressJS seem more reliable because it possibly is in certain areas.  &lt;/p&gt;

&lt;p&gt;Mandarine.TS has only been out there for a few months, and its community is still growing. Although, the fact that Mandarine is written in Typescript &amp;amp; runs on &lt;em&gt;Deno&lt;/em&gt; offers a now modern solution for future web-applications or applications in general with modern technologies. One of the most interesting things of Mandarine, is MQL (Mandarine Query Language) &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-data/mandarine-query-language"&gt;(See here)&lt;/a&gt;, which is some sort of version of CRUD repositories but implemented in Typescript.&lt;/p&gt;

&lt;p&gt;Another &lt;em&gt;&lt;strong&gt;+1&lt;/strong&gt;&lt;/em&gt; for mandarine is the fact that it supports Dependency Injection out of the box with its built-in DI framework &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts/mandarine-core/dependency-injection"&gt;(See documentation here)&lt;/a&gt;. This makes your application not only more easy to test, but it also makes it more readable &amp;amp; practice as it gets larger.&lt;/p&gt;

&lt;h1&gt;
  
  
  Thoughts
&lt;/h1&gt;

&lt;p&gt;It is definitely interesting where Mandarine.TS is going, while it may seem that it cannot fight against ExpressJS, some of its features and the possibly growing community will make its future something to be curious about. &lt;br&gt;
You can see &lt;a href="https://mandarineframework.gitbook.io/mandarine-ts"&gt;Mandarine's documentation here&lt;/a&gt; and you can access its &lt;a href="https://github.com/mandarineorg/mandarinets"&gt;&lt;strong&gt;Github&lt;/strong&gt; repository here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;I am the creator of Mandarine.TS&lt;/em&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>deno</category>
      <category>mandarinets</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
