added db for astro

This commit is contained in:
dswbx
2024-11-28 11:22:02 +01:00
parent bdc6eb55bf
commit 4693be5615
4 changed files with 18 additions and 9 deletions

View File

@@ -7,6 +7,8 @@
"start": "astro dev", "start": "astro dev",
"build": "astro check && astro build", "build": "astro check && astro build",
"preview": "astro preview", "preview": "astro preview",
"db": "turso dev --db-file test.db",
"db:check": "sqlite3 test.db \"PRAGMA wal_checkpoint(FULL);\"",
"astro": "astro" "astro": "astro"
}, },
"dependencies": { "dependencies": {

View File

@@ -13,6 +13,10 @@ const user = api.getUser();
<html> <html>
<body> <body>
<Admin withProvider={{ user }} config={{ basepath: "/admin" }} client:load /> <Admin
withProvider={{ user }}
config={{ basepath: "/admin" }}
client:load
/>
</body> </body>
</html> </html>

View File

@@ -3,8 +3,10 @@ import { App } from "bknd";
export const prerender = false; export const prerender = false;
let app: App;
export const ALL: APIRoute = async ({ request }) => { export const ALL: APIRoute = async ({ request }) => {
const app = App.create({ if (!app) {
app = App.create({
connection: { connection: {
type: "libsql", type: "libsql",
config: { config: {
@@ -14,5 +16,6 @@ export const ALL: APIRoute = async ({ request }) => {
}); });
await app.build(); await app.build();
}
return app.fetch(request); return app.fetch(request);
}; };

BIN
examples/astro/test.db Normal file

Binary file not shown.