diff --git a/examples/astro/package.json b/examples/astro/package.json
index a4f03f5..ed5f51e 100644
--- a/examples/astro/package.json
+++ b/examples/astro/package.json
@@ -7,6 +7,8 @@
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
+ "db": "turso dev --db-file test.db",
+ "db:check": "sqlite3 test.db \"PRAGMA wal_checkpoint(FULL);\"",
"astro": "astro"
},
"dependencies": {
diff --git a/examples/astro/src/pages/admin/[...admin].astro b/examples/astro/src/pages/admin/[...admin].astro
index 25f1aa7..50d5d2e 100644
--- a/examples/astro/src/pages/admin/[...admin].astro
+++ b/examples/astro/src/pages/admin/[...admin].astro
@@ -13,6 +13,10 @@ const user = api.getUser();
-
+
\ No newline at end of file
diff --git a/examples/astro/src/pages/api/[...api].ts b/examples/astro/src/pages/api/[...api].ts
index 401d118..5baa0fa 100644
--- a/examples/astro/src/pages/api/[...api].ts
+++ b/examples/astro/src/pages/api/[...api].ts
@@ -3,16 +3,19 @@ import { App } from "bknd";
export const prerender = false;
+let app: App;
export const ALL: APIRoute = async ({ request }) => {
- const app = App.create({
- connection: {
- type: "libsql",
- config: {
- url: "http://127.0.0.1:8080"
+ if (!app) {
+ app = App.create({
+ connection: {
+ type: "libsql",
+ config: {
+ url: "http://127.0.0.1:8080"
+ }
}
- }
- });
+ });
- await app.build();
+ await app.build();
+ }
return app.fetch(request);
};
diff --git a/examples/astro/test.db b/examples/astro/test.db
new file mode 100644
index 0000000..a614373
Binary files /dev/null and b/examples/astro/test.db differ