Repository
Current version released
3 years ago
🐍 nadder
nadder is an opinionated web server framework for Deno.
It includes URL Pattern routing, post-route middleware, helpers for creating/reading/manipulating cookies and responses, upgrading HTTP connections to WebSocket connections (inc. sorting into channels), PostgreSQL (or in-memory) session storage (inc. garbage collection and expiry), a React-free JSX transformer and atomic CSS with Uno.
Quick start
/**
* @jsx h
* @jsxFrag jsxFrag
*/
import 'https://deno.land/x/dotenv@v3.1.0/load.ts';
import nadder, {
Document,
h,
jsxFrag,
postgresConnection,
postgresSession,
} from 'https://deno.land/x/nadder@v0.2.0/mod.ts';
const postgres = postgresConnection({
password: Deno.env.get('POSTGRES_PWD'),
hostname: Deno.env.get('POSTGRES_HOST'),
}),
session = await postgresSession(postgres);
nadder.handleRoute('GET', '/{index.html}?', async (ctx) => {
const count = (((await session.get(ctx, 'count')) as number) ?? -1) + 1;
await session.set(ctx, 'count', count);
ctx.res.body = await Document(
'Home',
<>
<h1 class="text-green-600">Hello world!</h1>
<p>
Load count: <span class="font-bold">{count}</span>
</p>
</>
);
ctx.res.inferContentType('html');
});
nadder.listenAndServe();
All features are made available as exports of the mod.ts
file
and documented in the types.ts
file.
For convenience, the following dependencies are re-exported:
setCookie
,deleteCookie
,Cookie
,HTTPStatus
andHTTPStatusText
fromstd/http
.
Changes to this project are recorded in the CHANGELOG.
This project is licensed under the MIT License.
To support future development of this project, please consider sponsoring the author.