v3.0.1
A typed route string generator to help keep urls under control.
Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
@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