barebones docker | pocketbase | hono | svelte
This commit is contained in:
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
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 || '';
|
||||
const app = new Hono();
|
||||
app.get('/api/health', (c) => c.json({ status: 'ok' }));
|
||||
app.post('/api/debug/increment-hono', async (c) => {
|
||||
const auth = await fetch(`${PB_URL}/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_URL}/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_URL}/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 http://localhost:${info.port}`);
|
||||
});
|
||||
//# s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EAAE,UAAU,KAAK,EAAE,EAAE;KAC7C,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC;IAErC,MAAM,KAAK,CAAC,GAAG,MAAM,kCAAkC,eAAe,EAAE,EAAE;QACzE,MAAM,EAAE,OAAO;QACf,OAAO,EAAE;YACR,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,KAAK,EAAE;SAChC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,OAAO,GAAG,CAAC,EAAE,CAAC;KACjD,CAAC,CAAC;IAEH,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,MAAM,EAAE,EAAE,CAAC,CAAC;AAE5D,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;IAC1C,OAAO,CAAC,GAAG,CAAC,4CAA4C,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AACtE,CAAC,CAAC,CAAC"}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "proxy",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"build": "tsc",
|
||||
"start": "node dist/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hono/node-server": "^1.13.0",
|
||||
"hono": "^4.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^26.0.0",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.7.0"
|
||||
}
|
||||
}
|
||||
@@ -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}`);
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
Reference in New Issue
Block a user