Skip to content

Commit

Permalink
docs: update v1 to v2 (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhr authored Jun 27, 2023
1 parent 6ca9b97 commit 7ec06c9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ So, `routets` is deliberately less-featured. It just provides a basic building b
Create a file with the filename being `<your-route-name>.route.ts`, say `./greet.route.ts` here and the content is like this:

```typescript
import Route from "https://lib.deno.dev/x/routets@v1/Route.ts"
import Route from "https://lib.deno.dev/x/routets@v2/Route.ts"

export default new Route(async () => {
return new Response("Hello, World!")
Expand All @@ -35,7 +35,7 @@ export default new Route(async () => {
`routets` comes with a built-in CLI. During development, you can use this and serve your routes immediately:

```sh
$ deno install -Af https://lib.deno.dev/x/routets@v1/routets.ts
$ deno install -Af https://lib.deno.dev/x/routets@v2/routets.ts
$ routets # or `routets somewhere` to serve `somewhere/greet.route.ts` at `/greet`
Listening on http://localhost:8000/
```
Expand All @@ -45,7 +45,7 @@ And you'll see “Hello, World!” at [`http://localhost:8000/greet`](http://loc
Alternatively, of course you can create your own script:

```typescript
import Router from "https://lib.deno.dev/x/routets@v1/Router.ts"
import Router from "https://lib.deno.dev/x/routets@v2/Router.ts"
import { serve } from "https://deno.land/std@0.192.0/http/server.ts"

await serve(await new Router({ root: import.meta.resolve("./.") }))
Expand All @@ -60,7 +60,7 @@ await serve(await new Router({ root: import.meta.resolve("./.") }))
Matched parts of the pathname will be passed to the second argument of the handler. For example, when you have `:dynamic.route.ts` with the content being:

```typescript
import Route from "https://lib.deno.dev/x/routets@v1/Route.ts"
import Route from "https://lib.deno.dev/x/routets@v2/Route.ts"

export default new Route(async ({ slugs }) => {
return new Response(JSON.stringify(slugs), { headers: { "Content-Type": "application/json" } })
Expand Down Expand Up @@ -100,7 +100,7 @@ If you want to insert middlewares before/after an execution of handlers, you can
To exercise this, here we add support for returning a React element from handlers!

```typescript
import Route from "https://lib.deno.dev/x/routets@v1/Route.ts"
import Route from "https://lib.deno.dev/x/routets@v2/Route.ts"
import { renderToReadableStream } from "https://esm.sh/react-dom@18.2.0/server"
import { isValidElement, ReactElement, Suspense } from "https://esm.sh/react@18.2.0"

Expand Down

0 comments on commit 7ec06c9

Please sign in to comment.