mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 20:37:21 +00:00
refactored adapters to run test suites (#126)
* refactored adapters to run test suites * fix bun version for tests * added missing adapter tests and refactored examples to use `bknd.config.ts` where applicable
This commit is contained in:
23
examples/astro/src/bknd.ts
Normal file
23
examples/astro/src/bknd.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { AstroGlobal } from "astro";
|
||||
import { getApp as getBkndApp } from "bknd/adapter/astro";
|
||||
import config from "../bknd.config";
|
||||
|
||||
export { config };
|
||||
|
||||
export async function getApp() {
|
||||
return await getBkndApp(config);
|
||||
}
|
||||
|
||||
export async function getApi(
|
||||
astro: AstroGlobal,
|
||||
opts?: { mode: "static" } | { mode?: "dynamic"; verify?: boolean },
|
||||
) {
|
||||
const app = await getApp();
|
||||
if (opts?.mode !== "static" && opts?.verify) {
|
||||
const api = app.getApi({ headers: astro.request.headers });
|
||||
await api.verifyAuth();
|
||||
return api;
|
||||
}
|
||||
|
||||
return app.getApi();
|
||||
}
|
||||
Reference in New Issue
Block a user