feat: kimlik doğrulama, ödeme, kredi ve AI rapor sihirbazı ekle
- better-auth ile giriş/oturum yönetimi (src/lib/auth, giris sayfası) - iyzico ödeme entegrasyonu ve paket satın alma akışı - kredi sistemi ve uygulama veritabanı şeması (drizzle) - AI destekli rapor üretimi ve tercih sihirbazı - rapor yazdırma sayfası ve site header/kullanıcı menüsü Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
22
src/lib/appdb/index.ts
Normal file
22
src/lib/appdb/index.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { createClient, type Client } from "@libsql/client";
|
||||
import { drizzle } from "drizzle-orm/libsql";
|
||||
import * as schema from "./schema";
|
||||
|
||||
// Lokal: file:./data/app.db — deploy: libsql://... + auth token.
|
||||
// db.ts'teki better-sqlite3 bağlantısı gibi hot-reload'a karşı globalThis'te saklanır.
|
||||
|
||||
const globalForAppDb = globalThis as unknown as { __appDbClient?: Client };
|
||||
|
||||
function getClient(): Client {
|
||||
if (!globalForAppDb.__appDbClient) {
|
||||
const url = process.env.APP_DB_URL ?? "file:./data/app.db";
|
||||
globalForAppDb.__appDbClient = createClient({
|
||||
url,
|
||||
authToken: process.env.APP_DB_AUTH_TOKEN,
|
||||
});
|
||||
}
|
||||
return globalForAppDb.__appDbClient;
|
||||
}
|
||||
|
||||
export const appDb = drizzle(getClient(), { schema });
|
||||
export { schema };
|
||||
Reference in New Issue
Block a user