diff --git a/README.md b/README.md index cb712f6..defcd02 100644 --- a/README.md +++ b/README.md @@ -44,11 +44,30 @@ To do this, simply add the ref name to the sub-directory. > [🌍 Environment Variables](#-environment-variables) -2. Run this command +2. Follow the steps depending on the runtime - ```sh - deno run -A jsr:@5ouma/reproxy - ``` + - [🦕 Deno](https://deno.com) + + 1. Run this command + + ```sh + deno run -A jsr:@5ouma/reproxy + ``` + + - [🍞 Bun](https://bun.sh) + + 1. Add this code to the `index.ts` + + ```ts + import "@5ouma/reproxy"; + ``` + + 2. Run these commands + + ```sh + bunx jsr add @5ouma/reproxy + bun run index.ts + ```
@@ -67,6 +86,27 @@ To do this, simply add the ref name to the sub-directory. > [🌍 Environment Variables](#-environment-variables) +
+ +### ☁️ Use [Cloudflare Workers](https://workers.cloudflare.com) + +1. Set up the `wrangler.toml` + + > [🌍 Environment Variables](#-environment-variables) + +2. Add this code to the `index.ts` + + ```ts + import "@5ouma/reproxy"; + ``` + +3. Deploy with these commands + + ```sh + npx jsr add @5ouma/reproxy + npx wrangler deploy index.ts + ``` +

## 🔨 Development diff --git a/src/server.test.ts b/src/server.test.ts index 9340a1e..636f618 100644 --- a/src/server.test.ts +++ b/src/server.test.ts @@ -1,7 +1,7 @@ import { assertEquals } from "@std/assert"; import { STATUS_CODE } from "@std/http/status"; -import { app } from "./server.ts"; +import app from "./server.ts"; import { exportRepo, testRef, diff --git a/src/server.ts b/src/server.ts index 069d7a6..ae79aa1 100644 --- a/src/server.ts +++ b/src/server.ts @@ -21,7 +21,8 @@ import { checkRedirect, getContent, type Repository } from "./libs/mod.ts"; * }); * ``` */ -export const app: Hono = new Hono(); +const app: Hono = new Hono(); +export default app; app.use(logger()); app .get("/:ref?", async (ctx: Context) => { @@ -55,4 +56,4 @@ app return ctx.redirect("/", STATUS_CODE.SeeOther); }); -Deno.serve(app.fetch); +if (typeof Deno !== "undefined") Deno.serve(app.fetch);