Hi all, I’ve been using Deno the past few days for development in an Elm project and would like to report on my experience. In a word: Its great!!!. But first:
Below is my experience in two parts.
Part 1: Building a server
My first attempt using Deno, Typescript.
The code in
srcis working, while that in
src2is a rewrite-in-progress based on a different data model.
I had one issue that held me up for a day: you have to write your own OPTIONS handler. Thanks to all on Slack who helped me get through this.
The server uses the Oak middleware package.
Part 2: Script runner
I’ve always preferred writing little shell scripts to manage development. That said, the script runner part of
npm is really nice, despite the heavy baggage that comes with
node_modules, I am talking about you!
It turns out that there is another way: use velociraptor. The linked article, by velociraptor’s creator, Umberto Pepato (@umbo) explains how to install it and how to use it. In brief, you create a
yaml file which is the analogue of the scripts part of
package.json. Below is mine. It contains mixture of deno stuff and shell scripts. The first clause,
start ... could also have been written as a single line.
start: deno run src/server.ts --allow-net --allow-env ...
You run scripts by saying, for example,
vr start. Three cheers for Ryan Dahl and Umberto Pepato for creating these wonderful tools.
scripts: start: cmd: src/server.ts allow: - net - env - write - read test: cmd: src2/file.ts allow: - read - write ssh: ssh firstname.lastname@example.org upload: scp -r ./src email@example.com:/root/docserver upone: scp $1 firstname.lastname@example.org:/root/docserver