barebones docker | pocketbase | hono | svelte
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
//#region src/routes/app/debug/increment-svelte/+server.ts
|
||||
var { PB_URL = "http://127.0.0.1:8090", PB_SUPERUSER_EMAIL = "", PB_SUPERUSER_PASSWORD = "", DEBUG_RECORD_ID = "" } = process.env;
|
||||
async function POST() {
|
||||
const { token } = await (await fetch(`${PB_URL}/api/collections/_superusers/auth-with-password`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
identity: PB_SUPERUSER_EMAIL,
|
||||
password: PB_SUPERUSER_PASSWORD
|
||||
})
|
||||
})).json();
|
||||
const current = (await (await fetch(`${PB_URL}/api/collections/debug/records/${DEBUG_RECORD_ID}`, { headers: { Authorization: `Bearer ${token}` } })).json()).svelte_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({ svelte_count: current + 1 })
|
||||
});
|
||||
return new Response(JSON.stringify({ ok: true }), { headers: { "content-type": "application/json" } });
|
||||
}
|
||||
//#endregion
|
||||
export { POST };
|
||||
Reference in New Issue
Block a user