[PIE-28] Switch to type-safe API (#12)

Custom API client to handle a lot of the more type safe queries

Reviewed-on: #12
Co-authored-by: june <self@breadone.net>
Co-committed-by: june <self@breadone.net>
This commit was merged in pull request #12.
This commit is contained in:
2025-08-16 13:17:10 +12:00
committed by June
parent 0b1334d508
commit 6145f14df0
11 changed files with 116 additions and 71 deletions

View File

@@ -1,17 +1,7 @@
---
import client from "@/data/pocketbase";
const { class: className, recipe } = Astro.props
async function getLink(img: string) {
const record = await client.collection("images").getOne(img)
const link = await client.files.getRelativeURL(record, record.image)
return link
}
// Use Promise.all to wait for all async operations to complete
const links = await Promise.all(
recipe.images.map((img: string) => getLink(img))
)
const links = await client.getRecipeImages(recipe as string)
---