https://github.com/zaubrik/composium
Create handlers for Deno.serve. Powered by functional composition and the URL Pattern API.
https://github.com/zaubrik/composium
compose deno functional-programming router server urlpattern
Last synced: 6 months ago
JSON representation
Create handlers for Deno.serve. Powered by functional composition and the URL Pattern API.
- Host: GitHub
- URL: https://github.com/zaubrik/composium
- Owner: Zaubrik
- License: mit
- Created: 2022-06-28T06:57:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-02T12:26:19.000Z (over 1 year ago)
- Last Synced: 2025-02-17T00:05:24.255Z (8 months ago)
- Topics: compose, deno, functional-programming, router, server, urlpattern
- Language: TypeScript
- Homepage: https://dev.zaubrik.com/url-pattern
- Size: 71.3 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# composium
Powered by
[functional composition](https://en.wikipedia.org/wiki/Function_composition) and
the
[URL Pattern API](https://developer.mozilla.org/en-US/docs/Web/API/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](https://dev.zaubrik.com/url-pattern/).## Documentation
```bash
deno doc https://deno.land/x/composium/mod.ts
```## Example
```ts
import { Context, createDefaultHandler, createGetRoute } from "./mod.ts";function welcome(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](https://discord.gg/6spYphKXAt).