lucia-adapter-astrodb
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

lucia-adapter-astrodb

Astro DB adapter for Lucia.

npm i lucia-adapter-astrodb

Setup

You need to manually mark astro:db as an external dependency.

// astro.config.mjs
export default defineConfig({
	// ...
	vite: {
		optimizeDeps: {
			exclude: ["astro:db"]
		}
	}
});

Define the schema and initialize the adapter.

// db/config.ts
import { column, defineDb, defineTable } from "astro:db";

const User = defineTable({
	columns: {
		id: column.text({
			primaryKey: true
		})
	}
});

const Session = defineTable({
	columns: {
		id: column.text({
			primaryKey: true
		}),
		expiresAt: column.date(),
		userId: column.text({
			references: () => User.columns.id
		})
	}
});

export default defineDb({
	tables: {
		User,
		Session
	}
});
import { AstroDBAdapter } from "lucia-adapter-astrodb";
import { db, Session, User } from "astro:db";

const adapter = new AstroDBAdapter(db, Session, User);

Readme

Keywords

Package Sidebar

Install

npm i lucia-adapter-astrodb

Weekly Downloads

177

Version

0.0.9

License

MIT

Unpacked Size

7.71 kB

Total Files

5

Last publish

Collaborators

  • pilcrowonpaper