@friggframework/core 2.0.0--canary.461.fa770c1.0 → 2.0.0--canary.461.9c16b2e.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/database/prisma.js +29 -0
- package/package.json +5 -5
package/database/prisma.js
CHANGED
|
@@ -6,6 +6,32 @@ const { logger } = require('./encryption/logger');
|
|
|
6
6
|
const { Cryptor } = require('../encrypt/Cryptor');
|
|
7
7
|
const config = require('./config');
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Ensures DATABASE_URL is set for MongoDB connections
|
|
11
|
+
* Falls back to MONGO_URI if DATABASE_URL is not set
|
|
12
|
+
* Infrastructure layer concern - maps legacy MONGO_URI to Prisma's expected DATABASE_URL
|
|
13
|
+
*
|
|
14
|
+
* Note: This should only be called when DB_TYPE is 'mongodb'
|
|
15
|
+
*/
|
|
16
|
+
function ensureMongoDbUrl() {
|
|
17
|
+
// If DATABASE_URL is already set, use it
|
|
18
|
+
if (process.env.DATABASE_URL && process.env.DATABASE_URL.trim()) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Fallback to MONGO_URI for backwards compatibility with DocumentDB deployments
|
|
23
|
+
if (process.env.MONGO_URI && process.env.MONGO_URI.trim()) {
|
|
24
|
+
process.env.DATABASE_URL = process.env.MONGO_URI;
|
|
25
|
+
logger.debug('Using MONGO_URI as DATABASE_URL for MongoDB connection');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Neither is set - error
|
|
30
|
+
throw new Error(
|
|
31
|
+
'DATABASE_URL or MONGO_URI environment variable must be set for MongoDB'
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
9
35
|
function getEncryptionConfig() {
|
|
10
36
|
const STAGE = process.env.STAGE || process.env.NODE_ENV || 'development';
|
|
11
37
|
const shouldBypassEncryption = ['dev', 'test', 'local'].includes(STAGE);
|
|
@@ -99,6 +125,8 @@ const prismaClientSingleton = () => {
|
|
|
99
125
|
};
|
|
100
126
|
|
|
101
127
|
if (config.DB_TYPE === 'mongodb') {
|
|
128
|
+
// Ensure DATABASE_URL is set (fallback to MONGO_URI if needed)
|
|
129
|
+
ensureMongoDbUrl();
|
|
102
130
|
PrismaClient = loadPrismaClient('mongodb');
|
|
103
131
|
} else if (config.DB_TYPE === 'postgresql') {
|
|
104
132
|
PrismaClient = loadPrismaClient('postgresql');
|
|
@@ -181,4 +209,5 @@ module.exports = {
|
|
|
181
209
|
connectPrisma,
|
|
182
210
|
disconnectPrisma,
|
|
183
211
|
getEncryptionConfig,
|
|
212
|
+
ensureMongoDbUrl, // Exported for testing
|
|
184
213
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.461.
|
|
4
|
+
"version": "2.0.0--canary.461.9c16b2e.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.588.0",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@friggframework/eslint-config": "2.0.0--canary.461.
|
|
42
|
-
"@friggframework/prettier-config": "2.0.0--canary.461.
|
|
43
|
-
"@friggframework/test": "2.0.0--canary.461.
|
|
41
|
+
"@friggframework/eslint-config": "2.0.0--canary.461.9c16b2e.0",
|
|
42
|
+
"@friggframework/prettier-config": "2.0.0--canary.461.9c16b2e.0",
|
|
43
|
+
"@friggframework/test": "2.0.0--canary.461.9c16b2e.0",
|
|
44
44
|
"@prisma/client": "^6.17.0",
|
|
45
45
|
"@types/lodash": "4.17.15",
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "9c16b2ef70b6600db5b3b58b85210236ffec88ad"
|
|
84
84
|
}
|