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:
Our application will be very basic but we’re gonna have fun.
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:
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:
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