diff --git a/backend/db/index.ts b/backend/db/index.ts index 4bc7093..974f8d9 100644 --- a/backend/db/index.ts +++ b/backend/db/index.ts @@ -3,6 +3,8 @@ import { Pool } from "pg" import {secrets} from "../src/utils/secrets"; import * as schema from "./schema" + + export const pool = new Pool({ connectionString: secrets.DATABASE_URL, max: 10, // je nach Last diff --git a/backend/src/plugins/db.ts b/backend/src/plugins/db.ts index 9ad6377..36e46bc 100644 --- a/backend/src/plugins/db.ts +++ b/backend/src/plugins/db.ts @@ -1,9 +1,18 @@ import fp from "fastify-plugin" import {drizzle, NodePgDatabase} from "drizzle-orm/node-postgres" -import { db, pool } from "../../db" import * as schema from "../../db/schema" +import {secrets} from "../utils/secrets"; +import { Pool } from "pg" export default fp(async (server, opts) => { + + const pool = new Pool({ + connectionString: secrets.DATABASE_URL, + max: 10, // je nach Last + }) + + const db = drizzle(pool , {schema}) + // Dekorieren -> überall server.db server.decorate("db", db)