Many moving to Deno will be surprised to find they can't simply bootstrap an express web server in Deno. But, Deno offers a similar (and much improved) web server that is equally simple to stand up. Because of this we introduced 🍦 tasty! - A simple routing framework to serve simple APIs and websites using Deno.

Example Code:


import { serve, Server } from "https://deno.land/std@v0.42.0/http/server.ts";
import { tasty } from 'https://raw.githubusercontent.com/jquave/tasty/master/tasty.ts';

const s: Server = serve({ port: 8000 });

let router = new tasty.Router(s);

// Serve a static endpoint
router.on('/', (req) => {
    req.respond({ body: `Hello World!` })
});

// Serve a dynamic permalink
router.on('/:name', (req, query) => {
    req.respond({ body: `Hello ${query.get("name")}` })
});

Now run the simple web server with:

deno run --allow-net web.ts

Your now up and running with a hello world at http://localhost:8000 with an additional dynamic route at http://localhost:8000/YourName

Learn more on the official Github repository for tasty

Want interview questions delivered to your inbox?

Subscribe

Get CrunchSkills in your inbox weekly. Stay sharp for your next technical interview.