feat: init drizzle implementation for backend (express) and frontend (vite-react)

This commit is contained in:
afiqzudinhadi 2025-07-08 16:38:55 +08:00
parent fc3a21263a
commit aca6a4da98
17 changed files with 1608 additions and 35 deletions

View file

@ -1,6 +1,17 @@
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import dotenv from "dotenv";
dotenv.config({ path: ".env" });
const client = postgres(process.env.DATABASE_URL!);
let db_url = process.env.DATABASE_URL!;
try {
db_url = decodeURI(db_url);
} catch (e) {
console.warn("Failed to decode DATABASE_URL, using as is.");
}
console.log("Connecting to database URL:", db_url);
const client = postgres(db_url!);
export const db = drizzle(client);