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

0.2.0 • 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

6

Version

0.2.0

License

MIT

Unpacked Size

7.68 kB

Total Files

5

Last publish

Collaborators

  • pilcrowonpaper