diff --git a/apps/dokploy/proprietary/README.md b/apps/dokploy/proprietary/README.md deleted file mode 100644 index b1af288e6..000000000 --- a/apps/dokploy/proprietary/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Proprietary Features - -This directory contains all proprietary functionality of Dokploy. - -## Purpose - -This folder will house all **paid features** and premium functionality that are not part of the open source code. - -## License - -The code in this directory is under Dokploy's proprietary license. See [LICENSE_PROPRIETARY.md](../../../LICENSE_PROPRIETARY.md) for more details. - -## Contact - -If you want to learn more about our paid features or have any questions, please contact us at: - -- Email: [sales@dokploy.com](mailto:sales@dokploy.com) -- Contact Form: [https://dokploy.com/contact](https://dokploy.com/contact) diff --git a/apps/dokploy/server/db/index.ts b/apps/dokploy/server/db/index.ts new file mode 100644 index 000000000..afc10bedf --- /dev/null +++ b/apps/dokploy/server/db/index.ts @@ -0,0 +1,38 @@ +import { dbUrl } from "@dokploy/server/db/constants"; +import * as schema from "@dokploy/server/db/schema"; +import { and, eq } from "drizzle-orm"; +import { drizzle, type PostgresJsDatabase } from "drizzle-orm/postgres-js"; +import postgres from "postgres"; + +export { and, eq }; + +type Database = PostgresJsDatabase; +/** + * Evita problemas de redeclaración global en monorepos. + * No usamos `declare global`. + */ +const globalForDb = globalThis as unknown as { + db?: Database; +}; + +let dbConnection: Database; + +if (process.env.NODE_ENV === "production") { + // En producción no usamos global cache + dbConnection = drizzle(postgres(dbUrl), { + schema, + }); +} else { + // En desarrollo reutilizamos conexión para evitar múltiples conexiones + if (!globalForDb.db) { + globalForDb.db = drizzle(postgres(dbUrl), { + schema, + }); + } + + dbConnection = globalForDb.db; +} + +export const db: Database = dbConnection; + +export { dbUrl };