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 };
|
||||
@@ -0,0 +1,167 @@
|
||||
import { r as index_server_exports } from "../../chunks/internal.js";
|
||||
import { y as noop } from "../../chunks/shared.js";
|
||||
import "../../chunks/internal2.js";
|
||||
import "../../chunks/exports.js";
|
||||
import { _ as escape_html, b as writable, c as getContext, et as noop$1 } from "../../chunks/async.js";
|
||||
import "@sveltejs/kit/internal";
|
||||
import "@sveltejs/kit/internal/server";
|
||||
var PRELOAD_PRIORITIES = {
|
||||
tap: 1,
|
||||
hover: 2,
|
||||
viewport: 3,
|
||||
eager: 4,
|
||||
false: -1
|
||||
};
|
||||
({ ...PRELOAD_PRIORITIES }), PRELOAD_PRIORITIES.hover;
|
||||
/** @param {any} value */
|
||||
function notifiable_store(value) {
|
||||
const store = writable(value);
|
||||
let ready = true;
|
||||
function notify() {
|
||||
ready = true;
|
||||
store.update((val) => val);
|
||||
}
|
||||
/** @param {any} new_value */
|
||||
function set(new_value) {
|
||||
ready = false;
|
||||
store.set(new_value);
|
||||
}
|
||||
/** @param {(value: any) => void} run */
|
||||
function subscribe(run) {
|
||||
/** @type {any} */
|
||||
let old_value;
|
||||
return store.subscribe((new_value) => {
|
||||
if (old_value === void 0 || ready && new_value !== old_value) run(old_value = new_value);
|
||||
});
|
||||
}
|
||||
return {
|
||||
notify,
|
||||
set,
|
||||
subscribe
|
||||
};
|
||||
}
|
||||
var updated_listener = { v: noop };
|
||||
function create_updated_store() {
|
||||
const { set, subscribe } = writable(false);
|
||||
return {
|
||||
subscribe,
|
||||
check: async () => false
|
||||
};
|
||||
}
|
||||
var updated$1;
|
||||
var is_legacy = noop$1.toString().includes("$$") || /function \w+\(\) \{\}/.test(noop$1.toString());
|
||||
var placeholder_url = "a:";
|
||||
if (is_legacy) {
|
||||
new URL(placeholder_url);
|
||||
updated$1 = { current: false };
|
||||
} else {
|
||||
new class Page {
|
||||
data = {};
|
||||
form = null;
|
||||
error = null;
|
||||
params = {};
|
||||
route = { id: null };
|
||||
state = {};
|
||||
status = -1;
|
||||
url = new URL(placeholder_url);
|
||||
}();
|
||||
new class Navigating {
|
||||
current = null;
|
||||
}();
|
||||
updated$1 = new class Updated {
|
||||
current = false;
|
||||
}();
|
||||
updated_listener.v = () => updated$1.current = true;
|
||||
}
|
||||
//#endregion
|
||||
//#region ../node_modules/.pnpm/@sveltejs+kit@3.0.0-next.4_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.56.3_vite@8.0.16_831df308509456bf75377b19fdb5b8d4/node_modules/@sveltejs/kit/src/runtime/client/client.js
|
||||
/** @import { RemoteFunctionDataNode, ServerNodesResponse, ServerRedirectNode } from 'types' */
|
||||
/** @import { CacheEntry } from './remote-functions/cache.svelte.js' */
|
||||
/** @import { Query } from './remote-functions/query/instance.svelte.js' */
|
||||
/** @import { LiveQuery } from './remote-functions/query-live/instance.svelte.js' */
|
||||
var { onMount, tick } = index_server_exports;
|
||||
({
|
||||
url: /* @__PURE__ */ notifiable_store({}),
|
||||
page: /* @__PURE__ */ notifiable_store({}),
|
||||
navigating: /* @__PURE__ */ writable(null),
|
||||
updated: /* @__PURE__ */ create_updated_store()
|
||||
}).updated.check;
|
||||
//#endregion
|
||||
//#region ../node_modules/.pnpm/@sveltejs+kit@3.0.0-next.4_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.56.3_vite@8.0.16_831df308509456bf75377b19fdb5b8d4/node_modules/@sveltejs/kit/src/runtime/app/state/server.js
|
||||
function context() {
|
||||
return getContext("__request__");
|
||||
}
|
||||
//#endregion
|
||||
//#region ../node_modules/.pnpm/@sveltejs+kit@3.0.0-next.4_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.56.3_vite@8.0.16_831df308509456bf75377b19fdb5b8d4/node_modules/@sveltejs/kit/src/runtime/app/state/index.js
|
||||
/**
|
||||
* A read-only reactive object with information about the current page, serving several use cases:
|
||||
* - retrieving the combined `data` of all pages/layouts anywhere in your component tree (also see [loading data](https://svelte.dev/docs/kit/load))
|
||||
* - retrieving the current value of the `form` prop anywhere in your component tree (also see [form actions](https://svelte.dev/docs/kit/form-actions))
|
||||
* - retrieving the page state that was set through `goto`, `pushState` or `replaceState` (also see [goto](https://svelte.dev/docs/kit/$app-navigation#goto) and [shallow routing](https://svelte.dev/docs/kit/shallow-routing))
|
||||
* - retrieving metadata such as the URL you're on, the current route and its parameters, and whether or not there was an error
|
||||
*
|
||||
* ```svelte
|
||||
* <!--- file: +layout.svelte --->
|
||||
* <script>
|
||||
* import { page } from '$app/state';
|
||||
* <\/script>
|
||||
*
|
||||
* <p>Currently at {page.url.pathname}</p>
|
||||
*
|
||||
* {#if page.error}
|
||||
* <span class="red">Problem detected</span>
|
||||
* {:else}
|
||||
* <span class="small">All systems operational</span>
|
||||
* {/if}
|
||||
* ```
|
||||
*
|
||||
* Changes to `page` are available exclusively with runes. (The legacy reactivity syntax will not reflect any changes)
|
||||
*
|
||||
* ```svelte
|
||||
* <!--- file: +page.svelte --->
|
||||
* <script>
|
||||
* import { page } from '$app/state';
|
||||
* const id = $derived(page.params.id); // This will correctly update id for usage on this page
|
||||
* $: badId = page.params.id; // Do not use; will never update after initial load
|
||||
* <\/script>
|
||||
* ```
|
||||
*
|
||||
* On the server, values can only be read during rendering (in other words _not_ in e.g. `load` functions). In the browser, the values can be read at any time.
|
||||
*
|
||||
* @type {import('@sveltejs/kit').Page}
|
||||
*/
|
||||
var page = {
|
||||
get data() {
|
||||
return context().page.data;
|
||||
},
|
||||
get error() {
|
||||
return context().page.error;
|
||||
},
|
||||
get form() {
|
||||
return context().page.form;
|
||||
},
|
||||
get params() {
|
||||
return context().page.params;
|
||||
},
|
||||
get route() {
|
||||
return context().page.route;
|
||||
},
|
||||
get state() {
|
||||
return context().page.state;
|
||||
},
|
||||
get status() {
|
||||
return context().page.status;
|
||||
},
|
||||
get url() {
|
||||
return context().page.url;
|
||||
}
|
||||
};
|
||||
//#endregion
|
||||
//#region ../node_modules/.pnpm/@sveltejs+kit@3.0.0-next.4_@sveltejs+vite-plugin-svelte@7.1.2_svelte@5.56.3_vite@8.0.16_831df308509456bf75377b19fdb5b8d4/node_modules/@sveltejs/kit/src/runtime/components/error.svelte
|
||||
function Error$1($$renderer, $$props) {
|
||||
$$renderer.component(($$renderer) => {
|
||||
$$renderer.push(`<h1>${escape_html(page.status)}</h1> <p>${escape_html(page.error?.message)}</p>`);
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
export { Error$1 as default };
|
||||
@@ -0,0 +1,15 @@
|
||||
import { g as attr, n as head } from "../../chunks/async.js";
|
||||
//#region src/lib/assets/favicon.svg
|
||||
var favicon_default = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='107'%20height='128'%20viewBox='0%200%20107%20128'%3e%3ctitle%3esvelte-logo%3c/title%3e%3cpath%20d='M94.157%2022.819c-10.4-14.885-30.94-19.297-45.792-9.835L22.282%2029.608A29.92%2029.92%200%200%200%208.764%2049.65a31.5%2031.5%200%200%200%203.108%2020.231%2030%2030%200%200%200-4.477%2011.183%2031.9%2031.9%200%200%200%205.448%2024.116c10.402%2014.887%2030.942%2019.297%2045.791%209.835l26.083-16.624A29.92%2029.92%200%200%200%2098.235%2078.35a31.53%2031.53%200%200%200-3.105-20.232%2030%2030%200%200%200%204.474-11.182%2031.88%2031.88%200%200%200-5.447-24.116'%20style='fill:%23ff3e00'/%3e%3cpath%20d='M45.817%20106.582a20.72%2020.72%200%200%201-22.237-8.243%2019.17%2019.17%200%200%201-3.277-14.503%2018%2018%200%200%201%20.624-2.435l.49-1.498%201.337.981a33.6%2033.6%200%200%200%2010.203%205.098l.97.294-.09.968a5.85%205.85%200%200%200%201.052%203.878%206.24%206.24%200%200%200%206.695%202.485%205.8%205.8%200%200%200%201.603-.704L69.27%2076.28a5.43%205.43%200%200%200%202.45-3.631%205.8%205.8%200%200%200-.987-4.371%206.24%206.24%200%200%200-6.698-2.487%205.7%205.7%200%200%200-1.6.704l-9.953%206.345a19%2019%200%200%201-5.296%202.326%2020.72%2020.72%200%200%201-22.237-8.243%2019.17%2019.17%200%200%201-3.277-14.502%2017.99%2017.99%200%200%201%208.13-12.052l26.081-16.623a19%2019%200%200%201%205.3-2.329%2020.72%2020.72%200%200%201%2022.237%208.243%2019.17%2019.17%200%200%201%203.277%2014.503%2018%2018%200%200%201-.624%202.435l-.49%201.498-1.337-.98a33.6%2033.6%200%200%200-10.203-5.1l-.97-.294.09-.968a5.86%205.86%200%200%200-1.052-3.878%206.24%206.24%200%200%200-6.696-2.485%205.8%205.8%200%200%200-1.602.704L37.73%2051.72a5.42%205.42%200%200%200-2.449%203.63%205.79%205.79%200%200%200%20.986%204.372%206.24%206.24%200%200%200%206.698%202.486%205.8%205.8%200%200%200%201.602-.704l9.952-6.342a19%2019%200%200%201%205.295-2.328%2020.72%2020.72%200%200%201%2022.237%208.242%2019.17%2019.17%200%200%201%203.277%2014.503%2018%2018%200%200%201-8.13%2012.053l-26.081%2016.622a19%2019%200%200%201-5.3%202.328'%20style='fill:%23fff'/%3e%3c/svg%3e";
|
||||
//#endregion
|
||||
//#region src/routes/+layout.svelte
|
||||
function _layout($$renderer, $$props) {
|
||||
let { children } = $$props;
|
||||
head("12qhfyh", $$renderer, ($$renderer) => {
|
||||
$$renderer.push(`<link rel="icon"${attr("href", favicon_default)}/>`);
|
||||
});
|
||||
children($$renderer);
|
||||
$$renderer.push(`<!---->`);
|
||||
}
|
||||
//#endregion
|
||||
export { _layout as default };
|
||||
@@ -0,0 +1,7 @@
|
||||
import "../../chunks/async.js";
|
||||
//#region src/routes/+page.svelte
|
||||
function _page($$renderer) {
|
||||
$$renderer.push(`<h1>Welcome to SvelteKit</h1> <p>Visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to read the documentation</p>`);
|
||||
}
|
||||
//#endregion
|
||||
export { _page as default };
|
||||
@@ -0,0 +1,25 @@
|
||||
import PocketBase from "pocketbase";
|
||||
//#region src/lib/server/pocketbase.ts
|
||||
var pb = null;
|
||||
async function getPocketBase() {
|
||||
if (pb) return pb;
|
||||
const url = process.env.PB_URL || "http://127.0.0.1:8090";
|
||||
const email = process.env.PB_SUPERUSER_EMAIL || "";
|
||||
const password = process.env.PB_SUPERUSER_PASSWORD || "";
|
||||
pb = new PocketBase(url);
|
||||
await pb.admins.authWithPassword(email, password);
|
||||
return pb;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/routes/debug/+page.server.ts
|
||||
async function load() {
|
||||
const pb = await getPocketBase();
|
||||
const recordId = process.env.DEBUG_RECORD_ID || "";
|
||||
const record = await pb.collection("debug").getOne(recordId);
|
||||
return { initial: {
|
||||
hono_count: record.hono_count,
|
||||
svelte_count: record.svelte_count
|
||||
} };
|
||||
}
|
||||
//#endregion
|
||||
export { load };
|
||||
@@ -0,0 +1,12 @@
|
||||
import { _ as escape_html } from "../../../chunks/async.js";
|
||||
//#region src/routes/debug/+page.svelte
|
||||
function _page($$renderer, $$props) {
|
||||
$$renderer.component(($$renderer) => {
|
||||
let { data } = $$props;
|
||||
let honoCount = data.initial.hono_count;
|
||||
let svelteCount = data.initial.svelte_count;
|
||||
$$renderer.push(`<h1 class="svelte-1cmtigg">Debug Dashboard</h1> <div class="counters svelte-1cmtigg"><div class="card svelte-1cmtigg"><h2>Hono</h2> <p class="value svelte-1cmtigg">${escape_html(honoCount)}</p> <button class="svelte-1cmtigg">+1 Hono</button></div> <div class="card svelte-1cmtigg"><h2>SvelteKit</h2> <p class="value svelte-1cmtigg">${escape_html(svelteCount)}</p> <button class="svelte-1cmtigg">+1 Svelte</button></div></div>`);
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
export { _page as default };
|
||||
Reference in New Issue
Block a user