import { createDatabase } from "db0";
import sqlite from "db0/connectors/node-sqlite";
import { drizzle as Drizzle } from "db0/integrations/drizzle";
import path from "path";
import "dotenv/config";
const dbPath = path.resolve(process.env.DATABASE_PATH);
const db0 = createDatabase(
sqlite({
path: dbPath,
}),
);
const drizzle = Drizzle(db0);
export { db0, drizzle };
import { defineConfig } from "astro/config";
import tailwindcss from "@tailwindcss/vite";
import node from "@astrojs/node";
import vue from "@astrojs/vue";
import { db0 } from "./src/db/db.ts";
export default defineConfig({
vite: { plugins: [tailwindcss()] },
adapter: node({
mode: "standalone",
}),
output: "server",
session: {
driver: "db0",
cookie: {
name: "session",
sameSite: "lax",
maxAge: 3600,
},
options: {
database: db0,
table: "sessions",
},
},
integrations: [vue()],
});
This works fine when running the dev server. Problem is when building, I guess vite bundling gets in the way?
➜ astro-sandbox git:(master) ✗ node dist/server/entry.mjs
02:48:27 [@astrojs/node] Server listening on http://localhost:4321
[unstorage]: Database driver is experimental and behavior may change in the future.
02:48:30 [ERROR] TypeError: opts.database.sql is not a function
Any ideas of how to properly use the db0 adapter with sessions?