mirror of
https://github.com/shishantbiswas/bknd-examples.git
synced 2026-03-15 18:01:06 +00:00
All checks were successful
Build and Push to Gitea Registry / build-and-push (push) Successful in 6m40s
32 lines
594 B
TypeScript
32 lines
594 B
TypeScript
import { App } from "bknd";
|
|
import config from "../../bknd.config";
|
|
import { getApp as getBkndApp } from "bknd/adapter/tanstack-start";
|
|
|
|
declare global {
|
|
var __bknd: App | undefined
|
|
}
|
|
|
|
const getApp = async () => {
|
|
if (!global.__bknd) {
|
|
global.__bknd = await getBkndApp(config, process.env);
|
|
}
|
|
return global.__bknd;
|
|
}
|
|
|
|
export async function getApi({
|
|
headers,
|
|
verify,
|
|
}: {
|
|
verify?: boolean;
|
|
headers?: Headers;
|
|
}) {
|
|
const app = await getApp();
|
|
if (verify) {
|
|
const api = app.getApi({ headers });
|
|
await api.verifyAuth();
|
|
return api;
|
|
}
|
|
|
|
return app.getApi();
|
|
}
|