feat: init drizzle implementation for backend (express) and frontend (vite-react)
This commit is contained in:
parent
fc3a21263a
commit
aca6a4da98
17 changed files with 1608 additions and 35 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue