mirror of
https://github.com/hex248/sprint.git
synced 2026-02-09 10:43:02 +00:00
Add 'packages/backend/' from commit 'acce648ee5e7e3a3006451e637c0db654820cc48'
git-subtree-dir: packages/backend git-subtree-mainline:d0babd62afgit-subtree-split:acce648ee5
This commit is contained in:
22
packages/backend/src/db/client.ts
Normal file
22
packages/backend/src/db/client.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import "dotenv/config";
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
|
||||
if (!process.env.DATABASE_URL) {
|
||||
throw new Error("DATABASE_URL is not set in environment variables");
|
||||
}
|
||||
|
||||
export const db = drizzle({
|
||||
connection: {
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
},
|
||||
});
|
||||
|
||||
export const testDB = async () => {
|
||||
try {
|
||||
await db.execute("SELECT 1;");
|
||||
console.log("db connected");
|
||||
} catch (err) {
|
||||
console.log("db down");
|
||||
process.exit();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user