Skip to content

Commit

Permalink
initial rt commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Apr 2, 2024
0 parents commit c18a0da
Show file tree
Hide file tree
Showing 7 changed files with 474 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Check
"on":
push:
branches:
- main
pull_request:
branches:
- main
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- name: Format
run: deno fmt && git diff-index --quiet HEAD
- name: Lint
run: deno lint && git diff-index --quiet HEAD
17 changes: 17 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publish
"on":
push:
branches:
- main
workflow_dispatch: {}
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
- name: Publish package
run: deno publish
19 changes: 19 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"deno.enable": true,
"deno.unstable": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[markdown]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[jsonc]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[typescriptreact]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"files.eol": "\n"
}
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# rt

[![JSR][JSR badge]][JSR] [![JSR score][JSR score badge]][JSR score]
[![GitHub
Actions][GitHub Actions badge]][GitHub Actions]

Minimal HTTP router library based on the `URLPattern` API.

## Usage

```ts
import { createRouter } from "@fartlabs/rt";

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

Deno.serve((request) => router.fetch(request));
```

### Deno

1\. [Install Deno](https://docs.deno.com/runtime/manual).

2\. Start a new Deno project.

```sh
deno init
```

3\. Add rt as a project dependency.

```sh
deno add @fartlabs/rt
```

## Contribute

We appreciate your help!

### Style

Run `deno fmt` to format the code.

Run `deno lint` to lint the code.

---

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

[JSR]: https://jsr.io/@fartlabs/rt
[JSR badge]: https://jsr.io/badges/@fartlabs/rt
[JSR score]: https://jsr.io/@fartlabs/rt/score
[JSR score badge]: https://jsr.io/badges/@fartlabs/rt/score
[GitHub Actions]: https://github.com/FartLabs/rt/actions/workflows/check.yaml
[GitHub Actions badge]: https://github.com/FartLabs/rt/actions/workflows/check.yaml/badge.svg
11 changes: 11 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"lock": false,
"name": "@fartlabs/rt",
"version": "0.0.1",
"exports": {
".": "./mod.ts"
},
"tasks": {
"example": "deno run --allow-net examples/farm/farm.ts"
}
}
7 changes: 7 additions & 0 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @module
*
* rt is a minimalistic HTTP router library based on the `URLPattern` API.
*/

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

0 comments on commit c18a0da

Please sign in to comment.