a minimal web framework for deno
- lightweight and minimal
- built-in jsx/tsx rendering
- flexible type-safe routing with path parameters
- type-safe request/response handling
- middleware composition
- sse and websocket support
- static file serving with etag and range support
- type-safe data validation
- reactivity and signals
// ... deno.json
{
"imports": {
"@july/snarl": "jsr:@july/snarl"
},
"compilerOptions": {
"jsx": "precompile",
"jsxImportSource": "@july/snarl",
"lib": ["deno.ns", "dom", "dom.iterable"]
}
}import { createRouter, logger } from "@july/snarl";
const app = createRouter();
app.use(logger());
app.get("/", (ctx) => {
return ctx.html(
"<!DOCTYPE html>" + (
<html>
<head>
<title>example paige</title>
</head>
<body>
<h1>welcom</h1>
<p>i meant page* haiiiii</p>
</body>
</html>
),
);
});
app.get("/users/:id", (ctx) => {
const { id } = ctx.params;
return ctx.json({ user: id });
});
app.post("/users", async (ctx) => {
const body = await ctx.body();
return ctx.created(body);
});
Deno.serve(app.fetch);