An open API service indexing awesome lists of open source software.

https://github.com/virakkhun/cooed

yet another http routing ๐ŸŒ€
https://github.com/virakkhun/cooed

api deno http-server routing server web

Last synced: about 1 month ago
JSON representation

yet another http routing ๐ŸŒ€

Awesome Lists containing this project

README

          

# cooed ๐Ÿฆ•

cooed is a simple and minimal http routing library, to handle request `Request`
from Deno.serve.

features:

- routing ๐ŸŒ€
- group ๐ŸŒ€
- middleware ๐Ÿฅท
- static ๐Ÿ—’๏ธ

> example:

here is the small server setup to handle request from Deno.serve.

```ts
import { Cooed, RequestHandler, Static } from "@cooed/router";

const server = new Cooed({
static: new Static({
// dist is the location where the static content located
dir: "dist",
}),
});

const middleware: RequestHandler = (ctx) => {
if (ctx.request.method === "GET") {
return ctx.response.badRequest();
}
return next;
};

server.get("/", middleware, (ctx) => {
return ctx.response.json("Hello world!!").send();
});

const client = server.group("/client");

client.get("/", () => new Response("Hello client"));

// listen to Request through Deno.serve
Deno.serve({ port: 8000 }, async (req) => await server.serve(req));
```

๐Ÿงพ License

MIT License

Copyright (c) 2024 Virak Khun