jquave / tasty

🍦 Simple and sweet Deno Web Framework for building simple APIs and Websites
22 stars 5 forks source link
api deno https lightweight web

🍦 tasty! 🍦

A simple routing framework for Deno for serving simple websites. Created specifically as part of building https://crunchskills.com/

Features

Example Usage

web.ts:

import { serve, Server, ServerRequest } from "https://deno.land/std/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();

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

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

console.log("🍦 tasty! 🍦")
console.log("Serving up some tasty routes")

for await (const request of s) {
    router.route(request);
}

Run with

deno run --allow-net web.ts

Contributing

If you want to contribute to this project, feel free to make a fork, make changes on your fork, and then open a pull request here with an explanation of your changes.

Stuff that would be cool to add