made new client the default export
This commit is contained in:
parent
b514655b5c
commit
cf44f19310
@ -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<Recipe>(Collection.RECIPES).getList(page, perPage, options)
|
||||
}
|
||||
|
||||
@ -38,5 +38,5 @@ class APIClient {
|
||||
return await this.client.collection<Recipe>(Collection.RECIPES).getOne(id, { expand: 'ingredients,tags,steps' })
|
||||
}
|
||||
}
|
||||
|
||||
export const client2 = new APIClient()
|
||||
const client = new APIClient()
|
||||
export default client;
|
@ -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)
|
||||
---
|
||||
|
||||
<SiteLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user