improved astro adapter (serving api) + added documentation

This commit is contained in:
dswbx
2024-12-01 08:58:08 +01:00
parent b55fdd7516
commit feeb13c053
9 changed files with 166 additions and 23 deletions

View File

@@ -1,21 +1,12 @@
import type { APIRoute } from "astro";
import { App } from "bknd";
import { serve } from "bknd/adapter/astro";
export const prerender = false;
let app: App;
export const ALL: APIRoute = async ({ request }) => {
if (!app) {
app = App.create({
connection: {
type: "libsql",
config: {
url: "http://127.0.0.1:8080"
}
}
});
await app.build();
export const ALL = serve({
connection: {
type: "libsql",
config: {
url: "http://127.0.0.1:8080"
}
}
return app.fetch(request);
};
});