Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 1.17 KB

README.md

File metadata and controls

45 lines (32 loc) · 1.17 KB

composium

Powered by functional composition and the URL Pattern API, composium has become the most flexible routing framework in the world. Through its composability it can serve perfectly as a generic, abstract and minimal layer for your own back-end framework.

URL Pattern

The best way to learn and test the URL Pattern API is Zaubrik's free URL Pattern User Interface.

Documentation

deno doc https://deno.land/x/composium/mod.ts

Example

import { Context, createDefaultHandler, createGetRoute } from "./mod.ts";

function welcome<C extends Context>(ctx: C) {
  const name = ctx.result.pathname.groups.name || "nobody";
  ctx.response = new Response(`Welcome, ${name}!`);
  return ctx;
}

const route = createGetRoute({ pathname: "/{:name}?" })(welcome);
const handler = createDefaultHandler(route);

Deno.serve(handler);

// curl http://localhost:8080/Joe
// Welcome, Joe!

Discord

Feel free to ask questions and start discussions in our discord server.