Files
astro-pocketbase-continue/package/assets/middleware.ts
2025-10-05 13:52:22 +02:00

18 lines
682 B
TypeScript

// This file was automatically generated by Astro PocketBase.
import { defineMiddleware } from "astro:middleware";
import { helpersFrom } from "astro-pocketbase";
import PocketBase from "pocketbase";
const middleware = defineMiddleware((context, next) => {
const pocketbase = new PocketBase(import.meta.env.PUBLIC_ASTRO_POCKETBASE_URL);
const { getRecord, getRecords } = helpersFrom({ pocketbase });
context.locals.pocketbase = pocketbase;
context.locals.getRecord = getRecord;
context.locals.getRecords = getRecords;
return next();
});
// You should NOT change the exported name as it is used by the Astro PocketBase integration.
export { middleware as onRequest };