If you are reading this, there are high chances that you have written blog entries before or you are considering doing it. There are many platforms that can host your blog, like Blogger, WordPress, or Medium. But sometimes, you want to host your own blog. It could be because the type of post you want to write does not fit any of these platforms. Maybe you just want to stylize according to your very own aesthetic. Or you just want to test a new technology, like myself.

Our Project

If we develop our own blog, we need to store the blog entries somewhere. And we need to access them, to know which entries are there. We need a backend.

We will use Deno as the runtime for our backend. On top of it, we will use Alosaur as a web server framework. Since Deno is quite new, we will keep it simple and we will not connect to any database; a JSON file will keep track of which posts are available and we will serve them as HTML files.

Dino? As In Dinosaur?

No, Deno — although Deno’s icon is a cute dinosaur.

From its website:

Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.

Deno is created by Ryan Dahl, also known as the creator of Node.js. Deno started as a prototype to fix the regrets Ryan Dahl had with Node.js. If you are interested in these regrets, you can hear them from Ryan Dahl himself in this video.

Deno started its development in 2018, but just recently, May 13th, the development team released version 1.0.0, the first stable, ready for deploy version.

Deno comes with an extensive standard library, including I/O, formatting, and UUID generation among others. Furthermore, many third party modules exist. Deno’s development team hosts a curated list with many of them.

Alosaur

One of Deno’s third party modules is Alosaur — keeping with the dinosaur theme.

Alosaur is a controller based web server framework. It extensively uses decorators to indicate routes, similar to Nest. If you are familiar with Nest, with Alosaur you will feel right at home.

Hello Alosaur

Let us start with a Hello World Alosaur application. From there we will build up and abstract our application until its final result.

Since Alosaur uses decorators, we need to declare a tsconfig.json with the following options:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Our Hello World application looks like this:

#web-development #typescript #deno #javascript #node

Build Your Own Blog with Deno and Alpine.js
15.25 GEEK