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

https://github.com/liveblocks/zenrouter

An opinionated HTTP router with typed path params, built-in body validation, and a clean auth model.
https://github.com/liveblocks/zenrouter

Last synced: 2 months ago
JSON representation

An opinionated HTTP router with typed path params, built-in body validation, and a clean auth model.

Awesome Lists containing this project

README

          

# Zen Router


NPM

License: Apache 2.0

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.

**[Documentation](https://zenrouter.liveblocks.io/docs)**

## Installation

```
npm i @liveblocks/zenrouter
```

## Quick start

```ts
import { object, string } from "decoders";
import { ZenRouter } from "@liveblocks/zenrouter";

const zen = new ZenRouter(/* ... */);

zen.route(
"GET /greet/",

({ 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](https://liveblocks.io).

See [LICENSE](../../licenses/LICENSE-APACHE-2.0) for more information.