| 1 | export const app = new Hono(); |
| 2 | |
| 3 | app.get("/extra/secret-message", async (c) => { |
| 4 | const { key } = c.req.query(); |
| 5 | if (!key || !key.match(/^[a-z0-9]+$/)) { |
| 6 | return c.text("400 bad request", { status: 400 }); |
| 7 | } |
| 8 | const text = await Path.resolve(".clover/secret-message", key) |
| 9 | .readIfExists("utf-8"); |
| 10 | if (text) return c.text(text); |
| 11 | return c.text("401 not authorized", { status: 401 }); |
| 12 | }); |
| 13 | app.post("/admin/extra/secret-message", async (c) => { |
| 14 | const key = c.req.query("key"); |
| 15 | if (!key || !key.match(/^[a-z0-9]$/)) { |
| 16 | return c.text("400 bad request", { status: 400 }); |
| 17 | } |
| 18 | await Path.resolve(".clover/secret-message", key) |
| 19 | .writeMkdir(await c.req.text()); |
| 20 | return c.text("ok", { status: 200 }); |
| 21 | }); |
| 22 | |
| 23 | import { Path } from "#sitegen/path"; |
| 24 | import { Hono } from "hono"; |