@jmondi/route-strings
v3.0.3
Published
Manage and create typed route strings for your applications.
Downloads
2
Readme
@jmondi/route-strings
A typed route string generator to help keep urls under control.
Install
pnpm add @jmondi/route-strings
Deno
import { route } from "https://deno.land/x/route_strings/mod.ts";
Usage
import { Route } from "@jmondi/route-strings";
const r = route("/posts/:slug");
r.template;
// /posts/:slug
const r = route("/posts/:slug/random/:id");
r.create({ slug: "hello", id: 5 });
// /posts/hello/random/5
const g = routeGroup({ prefix: "/api/v1" });
const route = g.add("/posts/:slug/random/:id");
route.template;
// /api/v1/posts/:slug/random/:id
route.create({ slug: "hello", id: 5 });
// /api/v1/posts/hello/random/5