From cf44f19310295570ebcedf71e0ae4623786b734e Mon Sep 17 00:00:00 2001 From: june Date: Sat, 16 Aug 2025 12:28:42 +1200 Subject: [PATCH] made new client the default export --- src/data/pocketbase.ts | 16 ++++++++-------- src/pages/recipe/[recipeid].astro | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/data/pocketbase.ts b/src/data/pocketbase.ts index acb07d9..7fe09de 100644 --- a/src/data/pocketbase.ts +++ b/src/data/pocketbase.ts @@ -7,16 +7,16 @@ import { Collection } from './schema' -const client = new Pocketbase("http://localhost:4321") -client.autoCancellation(false) +const raw_client = new Pocketbase("http://localhost:4321") +raw_client.autoCancellation(false) // Return a relative url for file instead of full path including localhost, which breaks external access -client.files.getRelativeURL = (record: { [key: string]: any; }, filename: string, queryParams?: FileOptions | undefined) => { - const res = client.files.getURL(record, filename) +raw_client.files.getRelativeURL = (record: { [key: string]: any; }, filename: string, queryParams?: FileOptions | undefined) => { + const res = raw_client.files.getURL(record, filename) return res.substring(21) } -export default client; +export { raw_client }; class APIClient { client: Pocketbase @@ -26,7 +26,7 @@ class APIClient { this.client.autoCancellation(false) } - async getRecipesPaginated(page: number, perPage: number = 30, options: RecordListOptions) { + async getRecipesPage(page: number, perPage: number = 30, options: RecordListOptions) { return await this.client.collection(Collection.RECIPES).getList(page, perPage, options) } @@ -38,5 +38,5 @@ class APIClient { return await this.client.collection(Collection.RECIPES).getOne(id, { expand: 'ingredients,tags,steps' }) } } - -export const client2 = new APIClient() \ No newline at end of file +const client = new APIClient() +export default client; \ No newline at end of file diff --git a/src/pages/recipe/[recipeid].astro b/src/pages/recipe/[recipeid].astro index d422845..ffe0c54 100644 --- a/src/pages/recipe/[recipeid].astro +++ b/src/pages/recipe/[recipeid].astro @@ -1,5 +1,5 @@ --- -import client, { client2 } from "@/data/pocketbase"; +import client from "@/data/pocketbase"; import SiteLayout from "@/layouts/base"; import ImageCarousel from "@/components/Detail/ImageCarousel"; @@ -9,7 +9,7 @@ import InfoView from "@/components/Detail/InfoView"; const { recipeid } = Astro.params; -const re = await client2.getRecipe(recipeid as string) +const re = await client.getRecipe(recipeid as string) ---