|
4 | 4 | * Provides a router which specifically tailored for providing RESTful |
5 | 5 | * endpoints. |
6 | 6 | * |
7 | | - * ## Using with Deno |
| 7 | + * acorn works across [Deno runtime](https://deno.com/), |
| 8 | + * [Deno Deploy](https://deno.com/deploy), [Node.js](https://nodejs.org/), |
| 9 | + * [Bun](https://bun.sh/), |
| 10 | + * and [Cloudflare Workers](https://workers.cloudflare.com/). |
8 | 11 | * |
9 | | - * You need to reference the `@oak/acorn` package in code: |
| 12 | + * ## Installing |
| 13 | + * |
| 14 | + * @example Installing with Deno |
| 15 | + * |
| 16 | + * Add acorn to your project: |
| 17 | + * |
| 18 | + * ``` |
| 19 | + * deno add @oak/acorn |
| 20 | + * ``` |
| 21 | + * |
| 22 | + * @example Installing with Node.js or Cloudflare Workers |
| 23 | + * |
| 24 | + * Add acorn to your project with your preferred project manager. |
| 25 | + * |
| 26 | + * With npm: |
| 27 | + * |
| 28 | + * ``` |
| 29 | + * npx jsr add @oak/acorn |
| 30 | + * ``` |
| 31 | + * |
| 32 | + * With Yarn: |
| 33 | + * |
| 34 | + * ``` |
| 35 | + * yarn dlx jsr add @oak/acorn |
| 36 | + * ``` |
| 37 | + * |
| 38 | + * With pnpm: |
| 39 | + * |
| 40 | + * ``` |
| 41 | + * pnpm dlx jsr add @oak/acorn |
| 42 | + * ``` |
| 43 | + * |
| 44 | + * @example Install with Bun |
| 45 | + * |
| 46 | + * Add acorn to your project: |
| 47 | + * |
| 48 | + * ``` |
| 49 | + * bunx jsr add @oak/acorn |
| 50 | + * ``` |
| 51 | + * |
| 52 | + * ## Usage |
| 53 | + * |
| 54 | + * The main way of using acorn is to import the {@linkcode Router} into your |
| 55 | + * code and configure the router. |
| 56 | + * |
| 57 | + * If you are using Deno, Bun, or Node.js, after the router is configured, |
| 58 | + * invoke `.listen()` to start listening to requests. |
| 59 | + * |
| 60 | + * If you are using Cloudflare Workers, export the router as the default export |
| 61 | + * of the main module. |
| 62 | + * |
| 63 | + * @example Using with Deno, Bun and Node.js |
10 | 64 | * |
11 | | - * @example |
12 | 65 | * ```ts |
13 | | - * import { Router } from "jsr:@oak/acorn/router"; |
| 66 | + * import { Router } from "@oak/acorn"; |
14 | 67 | * |
15 | 68 | * const router = new Router(); |
16 | 69 | * |
|
26 | 79 | * router.listen({ port: 3000 }); |
27 | 80 | * ``` |
28 | 81 | * |
29 | | - * ## Using with Bun |
30 | | - * |
31 | | - * You need to install/add the package to your project via: |
| 82 | + * @example Using with Cloudflare Workers |
32 | 83 | * |
33 | | - * ``` |
34 | | - * bunx jsr add @oak/acorn |
35 | | - * ``` |
36 | | - * |
37 | | - * And then you import it into your project: |
38 | | - * |
39 | | - * @example |
40 | 84 | * ```ts |
41 | 85 | * import { Router } from "@oak/acorn/router"; |
42 | 86 | * |
|
51 | 95 | * |
52 | 96 | * router.get("/books/:id", (ctx) => BOOKS[ctx.params.id]); |
53 | 97 | * |
54 | | - * router.listen({ port: 3000 }); |
| 98 | + * export default router; |
55 | 99 | * ``` |
56 | 100 | * |
57 | 101 | * @module |
|
0 commit comments