This commit is contained in:
2026-05-11 12:23:57 +02:00
commit 72337e801c
34 changed files with 1573 additions and 0 deletions

22
src/lib/server/auth.ts Normal file
View File

@@ -0,0 +1,22 @@
import { betterAuth } from 'better-auth/minimal';
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
import { sveltekitCookies } from 'better-auth/svelte-kit';
import { env } from '$env/dynamic/private';
import { getRequestEvent } from '$app/server';
import { db } from '$lib/server/db';
export const auth = betterAuth({
baseURL: env.ORIGIN,
secret: env.BETTER_AUTH_SECRET,
database: drizzleAdapter(db, { provider: 'pg' }),
emailAndPassword: { enabled: true },
socialProviders: {
github: {
clientId: env.GITHUB_CLIENT_ID,
clientSecret: env.GITHUB_CLIENT_SECRET
}
},
plugins: [
sveltekitCookies(getRequestEvent) // make sure this is the last plugin in the array
]
});

View File

@@ -0,0 +1 @@
// If you see this file, you have not run the auth:schema script yet, but you should!

View File

@@ -0,0 +1,10 @@
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import * as schema from './schema';
import { env } from '$env/dynamic/private';
if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
const client = postgres(env.DATABASE_URL);
export const db = drizzle(client, { schema });

View File

@@ -0,0 +1,9 @@
import { pgTable, serial, integer, text } from 'drizzle-orm/pg-core';
export const task = pgTable('task', {
id: serial('id').primaryKey(),
title: text('title').notNull(),
priority: integer('priority').notNull().default(1)
});
export * from './auth.schema';