Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal HTTP router in JSX #3

Merged
merged 5 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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