diff options
| author | seth <[email protected]> | 2023-11-12 00:56:18 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2023-11-12 00:56:18 -0500 |
| commit | 2e64b8579fed604306958b89271ad068df2f54ce (patch) | |
| tree | 2d94cce07b92f68201669a59283ce150e6878a0c /src | |
| parent | 70edf4c616e59a8e83e7ca7faf9faefd6e0b817c (diff) | |
fix: route static files correctly
Diffstat (limited to 'src')
| -rw-r--r-- | src/index.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/index.ts b/src/index.ts index 55bd92a..da1fa4a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,14 +1,12 @@ import { Hono } from "hono"; import { logger } from "hono/logger"; import { prettyJSON } from "hono/pretty-json"; -import { secureHeaders } from "hono/secure-headers"; import { zValidator } from "@hono/zod-validator"; import { list } from "./schemas"; import { Bindings, Variables } from "./env"; const app = new Hono<{ Bindings: Bindings; Variables: Variables }>(); -app.use("*", secureHeaders()); app.use("*", logger()); app.use("*", prettyJSON()); @@ -16,7 +14,7 @@ app.get("/", (c) => { return c.redirect(c.env.REDIRECT_ROOT ?? "https://github.com/getchoo/teawieAPI"); }); -app.get("/static/teawie/*", async (c) => { +app.get("/static/*", async (c) => { return await c.env.ASSETS.fetch(c.req.raw); }); @@ -32,13 +30,16 @@ app.get("/list_teawies", zValidator("query", list), async (c) => { ); }); -app.get("/random_teawie", async (c) => { - const wies = WIES; - const wie = wies[Math.floor(Math.random() * wies.length)]; +app.get("/random_teawie", (c) => { + const wie = WIES[Math.floor(Math.random() * WIES.length)]; return c.json({ url: `${c.env.URL ?? "https://api.mydadleft.me"}/static/${wie}`, }); }); +app.get("/get_random_teawie", (c) => { + return c.redirect(`${c.env.URL ?? "https://api.mydadleft.me"}/random_teawie`); +}); + export default app; |
