Skip to content

Commit

Permalink
Minimal HTTP router in JSX (#3)
Browse files Browse the repository at this point in the history
* introduce jsonx components

* move core library to `@fartlabs/rt`

* Update deno.jsonc

* Update README.md
  • Loading branch information
EthanThatOneKid authored Apr 2, 2024
1 parent d6a8fa5 commit 71a4259
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 332 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
[![GitHub
Actions][GitHub Actions badge]][GitHub Actions]

Minimal HTTP router library based on the `URLPattern` API.
> [!NOTE]
>
> Built with [**@fartlabs/rt**](https://github.com/FartLabs/rt) and
> [**@fartlabs/jsonx**](https://github.com/FartLabs/jsonx).
Minimal HTTP router library based on the `URLPattern` API in JSX.

## Usage

```ts
import { createRouter } from "@fartlabs/rtx";
```tsx
import { Get } from "@fartlabs/rtx";

const router = createRouter()
.get("/", () => {
return new Response("Hello, World!");
})
.default(() => new Response("Not found", { status: 404 }));
const router = <Get pattern="/" handle={() => new Response("Hello, World!")} />;

Deno.serve((request) => router.fetch(request));
```
Expand Down Expand Up @@ -46,11 +47,11 @@ Run `deno lint` to lint the code.

---

Developed with ❤️ by [**@EthanThatOneKid**](https://etok.codes/)
Developed with ❤️ [**@FartLabs**](https://github.com/FartLabs)

[JSR]: https://jsr.io/@fartlabs/rtx
[JSR badge]: https://jsr.io/badges/@fartlabs/rtx
[JSR score]: https://jsr.io/@fartlabs/rtx/score
[JSR score badge]: https://jsr.io/badges/@fartlabs/rtx/score
[GitHub Actions]: https://github.com/EthanThatOneKid/rtx/actions/workflows/check.yaml
[GitHub Actions badge]: https://github.com/EthanThatOneKid/rtx/actions/workflows/check.yaml/badge.svg
[GitHub Actions]: https://github.com/FartLabs/rtx/actions/workflows/check.yaml
[GitHub Actions badge]: https://github.com/FartLabs/rtx/actions/workflows/check.yaml/badge.svg
8 changes: 5 additions & 3 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"version": "0.0.1",
"exports": "./mod.ts",
"imports": {
"rtx/": "./"
"@fartlabs/jsonx": "jsr:@fartlabs/jsonx@^0.0.10",
"@fartlabs/rt": "jsr:@fartlabs/rt@^0.0.1"
},
"tasks": {
"example": "deno run --allow-net examples/farm/farm.ts"
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@fartlabs/jsonx"
}
}
11 changes: 0 additions & 11 deletions examples/farm/farm.ts

This file was deleted.

7 changes: 6 additions & 1 deletion mod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/**
* @module
*
* rtx is a minimalistic HTTP router library based on the `URLPattern` API.
* rtx is a minimalistic HTTP router library based on the `URLPattern` API in
* JSX.
*/

import * as rtx from "./rtx.ts";

rtx satisfies rtx.ComponentsInterface;

export * from "./rtx.ts";
Loading

0 comments on commit 71a4259

Please sign in to comment.