diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..daa0323 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,23 @@ +name: Publish +on: + workflow_dispatch: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + + permissions: + contents: read + id-token: write + + steps: + - uses: actions/checkout@v4 + - name: Install Deno + uses: denoland/setup-deno@v1 + with: + deno-version: canary + + - name: Publish package + run: deno publish \ No newline at end of file diff --git a/README.md b/README.md index bf005e5..8bbdc32 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,19 @@ await Deno.serve( ).finished; ``` +## Usage with `deno serve` + +```ts +import { router } from "jsr:@denosaurs/rutt"; + +export default { + fetch: router({ + "/hello/:name": (_req, _, { name }) => + new Response(`Hello ${name}`, { status: 200 }), + }), +}; +``` + ## Projects using `rutt` - [denoland/fresh](https://github.com/denoland/fresh) diff --git a/deno.json b/deno.json index 623b871..b0f8e35 100644 --- a/deno.json +++ b/deno.json @@ -2,7 +2,8 @@ "name": "@denosaurs/rutt", "version": "0.1.0", "imports": { - "https://deno.land/x/rutt/mod.ts": "./mod.ts" + "https://deno.land/x/rutt/mod.ts": "./mod.ts", + "jsr:@denosaurs/rutt": "./mod.ts" }, "exports": "./mod.ts" diff --git a/examples/hello_world.ts b/examples/hello_world.ts index 4634192..d277c7d 100644 --- a/examples/hello_world.ts +++ b/examples/hello_world.ts @@ -1,4 +1,4 @@ -import { router } from "https://deno.land/x/rutt/mod.ts"; +import { router } from "jsr:@denosaurs/rutt"; await Deno.serve( router({ diff --git a/examples/nested_routes.ts b/examples/nested_routes.ts index 497e912..ed041e2 100644 --- a/examples/nested_routes.ts +++ b/examples/nested_routes.ts @@ -1,4 +1,4 @@ -import { router } from "https://deno.land/x/rutt/mod.ts"; +import { router } from "jsr:@denosaurs/rutt"; await Deno.serve( router({ diff --git a/examples/parameters.ts b/examples/parameters.ts index 9af720d..70e2981 100644 --- a/examples/parameters.ts +++ b/examples/parameters.ts @@ -1,4 +1,4 @@ -import { router } from "https://deno.land/x/rutt/mod.ts"; +import { router } from "jsr:@denosaurs/rutt"; await Deno.serve( router({ diff --git a/examples/serve.ts b/examples/serve.ts new file mode 100644 index 0000000..5b77b2c --- /dev/null +++ b/examples/serve.ts @@ -0,0 +1,8 @@ +import { router } from "jsr:@denosaurs/rutt"; + +export default { + fetch: router({ + "/hello/:name": (_req, _, { name }) => + new Response(`Hello ${name}`, { status: 200 }), + }), +}; diff --git a/test.ts b/test.ts index 51e4d68..3165a7e 100644 --- a/test.ts +++ b/test.ts @@ -1,5 +1,5 @@ -import { assert, assertEquals, assertIsError } from "jsr:@std/assert@1.0.0"; -import { router } from "https://deno.land/x/rutt/mod.ts"; +import { assert, assertEquals, assertIsError } from "jsr:@std/assert@1.0.5"; +import { router } from "jsr:@denosaurs/rutt"; /// @ts-ignore - Deno doesn't have this type const TEST_CONN_INFO: Deno.ServeHandlerInfo = {