@liveblocks/zenrouter
v1.2.0
Published
An opinionated HTTP router with typed path params, built-in body validation, and a clean auth model.
Downloads
12,252
Readme
Zen Router
An opinionated API router with typed path params, built-in body validation, and a clean auth model. Built for Cloudflare Workers, Bun, Node.js, and every other modern JavaScript runtime.
Installation
npm i @liveblocks/zenrouterQuick start
import { object, string } from "decoders";
import { ZenRouter } from "@liveblocks/zenrouter";
const zen = new ZenRouter(/* ... */);
zen.route(
"GET /greet/<name>",
({ p }) => ({ result: `Hi, ${p.name}!` })
);
zen.route(
"POST /greet",
object({ name: string }),
({ body }) => ({
result: `Hi, ${body.name}!`,
})
);
export default zen;License
Licensed under the Apache License 2.0, Copyright © 2021-present Liveblocks.
See LICENSE for more information.
