Skip to content

liveblocks/zenrouter

Repository files navigation

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

Installation

npm i @liveblocks/zenrouter

Quick 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.

About

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

Resources

License

Stars

Watchers

Forks

Contributors