Recently Deno (An alternative to Node.js) has released. A lot of peoples are talking about it as it is new and sounds to have some cool features. Today, we will make a simple To-Do app with Deno as a REST API.

We will see these different things:

  • Oak (An HTTP Framework like Express.js)
  • Denon (Alternative to Nodemon)
  • Realizing a CRUD

Our application will be very basic but we’re gonna have fun.


Setup the environment

As we are new to Deno, we need to install it:

On macOS / Linux:

curl -fsSL https://deno.land/x/install/install.sh | sh

On windows:

iwr https://deno.land/x/install/install.ps1 -useb | iex

Once you have installed Deno, you will be able to launch it:

deno

As we don’t like to rerun the app every time we make a modification, we will use Denon (An alternative to Nodemon):

deno install --allow-read --allow-run --allow-write --allow-net -f --unstable https://deno.land/x/denon@v2.2.0/denon.ts

Bonus

If you are using VS Code, you can install the Deno extension:

  • Find modules by URL
  • Cache remote imports

Creating our project

Now that our environment is ready, we can begin to code. Let’s create a new folder and run this command:

denon --init

It will generate a Denon file to run your scripts (A bit like package.json):

We can now create our entry file under src/index.ts

This file is very simple, it does:

  • Create the server with Oak on port 3000
  • Serves routes from “router.ts”

So, we need to create the router file:

The router will import the controllers and serve it on different URLs.

#javascript #react-native #api #deno #nodejs #react

A Simple To-Do app with Deno & React Native
22.40 GEEK