Skip to Content
Senri
Runtimes

Deno

Run on Deno. Install from JSR, permission flags, and passing the app to Deno.serve

src/main.ts
import {  } from "@senrijs/senri";
import {  } from "@senrijs/senri/serve";

const  = ();
.("/", () => "Hello, Deno!");

await ();   // http://localhost:3927
deno run --watch --allow-net --allow-env=PORT,NODE_ENV src/main.ts   # the template's deno task dev

For a new app, the template is the quickest way.

deno run -A npm:create-senri my-app --template deno

To add it to an existing project, install it from JSR.

deno add jsr:@senrijs/senri

Permission flags

FlagWhen you need it
--allow-netAlways (to listen)
--allow-env=PORTTo set the port with the PORT environment variable. Without it, 3927 is used without a prompt
--allow-env=NODE_ENVTo use devtools(). Without it, Senri cannot tell whether this is production, so development mode stays off (and a one-line notice is printed)

Pass the app to Deno.serve yourself

When you call Deno.serve yourself, pass app.fetch.

.({ : 3927 }, .);

Then, unlike with serve(), deciding the port, printing the routes and waiting for in-flight requests when stopping are up to you.

Run in production

Start with NODE_ENV=production. Even if devtools() is still there, it gives no development output.

NODE_ENV=production deno run --allow-net --allow-env=PORT,NODE_ENV src/main.ts

On this page