barebones docker | pocketbase | hono | svelte

This commit is contained in:
JCEEE
2026-06-23 21:49:54 +01:00
parent 2253b54077
commit f9d9fa9ace
105 changed files with 27341 additions and 97 deletions
+61
View File
@@ -0,0 +1,61 @@
import { serve } from "@hono/node-server";
import { Hono } from "hono";
// const PB_URL = process.env.PB_URL || 'http://127.0.0.1:8090';
// const PB_EMAIL = process.env.PB_SUPERUSER_EMAIL || '';
// const PB_PASSWORD = process.env.PB_SUPERUSER_PASSWORD || '';
// const DEBUG_RECORD_ID = process.env.DEBUG_RECORD_ID || '';
import {
SERVER_IP,
PB_PORT,
PB_EMAIL,
PB_PASSWORD,
DEBUG_RECORD_ID,
} from "../../config.ts";
const app = new Hono();
const PB_ENDPOINT = `http://${SERVER_IP}:${PB_PORT}`;
app.get("/api/health", (c) => c.json({ status: "ok" }));
app.post("/api/increment-hono", async (c) => {
const auth = await fetch(
`${PB_ENDPOINT}/api/collections/_superusers/auth-with-password`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ identity: PB_EMAIL, password: PB_PASSWORD }),
},
);
const { token } = await auth.json();
const record = await fetch(
`${PB_ENDPOINT}/api/collections/debug/records/${DEBUG_RECORD_ID}`,
{
headers: { Authorization: `Bearer ${token}` },
},
);
const data = await record.json();
const current = data.hono_count || 0;
await fetch(
`${PB_ENDPOINT}/api/collections/debug/records/${DEBUG_RECORD_ID}`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ hono_count: current + 1 }),
},
);
return c.json({ ok: true });
});
const port = parseInt(process.env.PROXY_PORT || "3456", 10);
serve({ fetch: app.fetch, port }, (info) => {
console.log(`Hono proxy listening on ${SERVER_IP}:${info.port}`);
});