@friggframework/core 2.0.0--canary.419.e387a34.0 → 2.0.0--canary.419.e82b061.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/mongo.js +73 -33
- package/package.json +5 -5
package/database/mongo.js
CHANGED
|
@@ -25,7 +25,10 @@ try {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
} catch (error) {
|
|
28
|
-
debug(
|
|
28
|
+
debug(
|
|
29
|
+
'Could not load app definition for DocumentDB configuration:',
|
|
30
|
+
error.message
|
|
31
|
+
);
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
// Buffering means mongoose will queue up operations if it gets
|
|
@@ -39,48 +42,85 @@ const mongoConfig = {
|
|
|
39
42
|
serverSelectionTimeoutMS: 5000,
|
|
40
43
|
};
|
|
41
44
|
|
|
45
|
+
console.log('📁 AppDefinition content:', JSON.stringify(appDefinition));
|
|
46
|
+
|
|
42
47
|
// Add DocumentDB TLS configuration if enabled
|
|
43
48
|
if (appDefinition.database?.documentDB?.enable === true) {
|
|
44
49
|
console.log('📄 DocumentDB configuration detected, enabling TLS');
|
|
45
50
|
console.log('📁 Current working directory:', process.cwd());
|
|
46
|
-
console.log(
|
|
47
|
-
|
|
51
|
+
console.log(
|
|
52
|
+
'📋 App definition database config:',
|
|
53
|
+
JSON.stringify(appDefinition.database, null, 2)
|
|
54
|
+
);
|
|
55
|
+
|
|
48
56
|
mongoConfig.tls = true;
|
|
49
|
-
|
|
57
|
+
|
|
50
58
|
// Set TLS CA file path if specified
|
|
51
59
|
if (appDefinition.database.documentDB.tlsCAFile) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
console.log('
|
|
72
|
-
fs.readdirSync(securityDir).forEach(item => {
|
|
73
|
-
console.log(` 📄 ${item}`);
|
|
74
|
-
});
|
|
60
|
+
const tlsCAFile = appDefinition.database.documentDB.tlsCAFile;
|
|
61
|
+
|
|
62
|
+
// Basic safety: reject obviously dangerous paths
|
|
63
|
+
if (tlsCAFile.includes('..') || path.isAbsolute(tlsCAFile)) {
|
|
64
|
+
console.warn(
|
|
65
|
+
'⚠️ Rejecting potentially unsafe tlsCAFile path:',
|
|
66
|
+
tlsCAFile
|
|
67
|
+
);
|
|
68
|
+
} else {
|
|
69
|
+
const tlsCAFilePath = path.resolve(process.cwd(), tlsCAFile);
|
|
70
|
+
|
|
71
|
+
console.log('📄 DocumentDB TLS CA file configured:');
|
|
72
|
+
console.log(' 📎 Original path:', tlsCAFile);
|
|
73
|
+
console.log(' 📎 Resolved path:', tlsCAFilePath);
|
|
74
|
+
console.log(' 📄 File exists:', fs.existsSync(tlsCAFilePath));
|
|
75
|
+
|
|
76
|
+
// Only set tlsCAFile if the file actually exists
|
|
77
|
+
if (fs.existsSync(tlsCAFilePath)) {
|
|
78
|
+
mongoConfig.tlsCAFile = tlsCAFilePath;
|
|
79
|
+
console.log('✅ TLS CA file configured successfully');
|
|
75
80
|
} else {
|
|
76
|
-
console.
|
|
81
|
+
console.error(
|
|
82
|
+
'❌ TLS CA file not found, continuing without certificate'
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Debug directory listing (only in development)
|
|
87
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
88
|
+
try {
|
|
89
|
+
console.log('📁 Current directory contents:');
|
|
90
|
+
fs.readdirSync(process.cwd()).forEach((item) => {
|
|
91
|
+
const stats = fs.statSync(
|
|
92
|
+
path.join(process.cwd(), item)
|
|
93
|
+
);
|
|
94
|
+
console.log(
|
|
95
|
+
` ${stats.isDirectory() ? '📁' : '📄'} ${item}`
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const securityDir = path.join(process.cwd(), 'security');
|
|
100
|
+
if (fs.existsSync(securityDir)) {
|
|
101
|
+
console.log('📁 Security directory contents:');
|
|
102
|
+
fs.readdirSync(securityDir).forEach((item) => {
|
|
103
|
+
console.log(` 📄 ${item}`);
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
console.log(
|
|
107
|
+
'❌ Security directory does not exist at:',
|
|
108
|
+
securityDir
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.log(
|
|
113
|
+
'❌ Error listing directory contents:',
|
|
114
|
+
error.message
|
|
115
|
+
);
|
|
116
|
+
}
|
|
77
117
|
}
|
|
78
|
-
} catch (error) {
|
|
79
|
-
console.log('❌ Error listing directory contents:', error.message);
|
|
80
118
|
}
|
|
81
119
|
}
|
|
82
120
|
} else {
|
|
83
|
-
console.log(
|
|
121
|
+
console.log(
|
|
122
|
+
'📄 DocumentDB not enabled, using standard MongoDB configuration'
|
|
123
|
+
);
|
|
84
124
|
}
|
|
85
125
|
|
|
86
126
|
const checkIsConnected = () => mongoose.connection?.readyState > 0;
|
|
@@ -94,10 +134,10 @@ const connectToDatabase = async () => {
|
|
|
94
134
|
console.log('🔗 Connecting to database...');
|
|
95
135
|
console.log('🔗 MongoDB URI:', process.env.MONGO_URI ? 'SET' : 'NOT SET');
|
|
96
136
|
console.log('🔧 Final mongoConfig:', JSON.stringify(mongoConfig, null, 2));
|
|
97
|
-
|
|
137
|
+
|
|
98
138
|
debug('=> using new database connection');
|
|
99
139
|
await mongoose.connect(process.env.MONGO_URI, mongoConfig);
|
|
100
|
-
debug('Connection state:',
|
|
140
|
+
debug('Connection state:', mongoose.STATES[mongoose.connection.readyState]);
|
|
101
141
|
mongoose.connection.on('error', (error) => flushDebugLog(error));
|
|
102
142
|
};
|
|
103
143
|
|
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.419.
|
|
4
|
+
"version": "2.0.0--canary.419.e82b061.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/boom": "^10.0.1",
|
|
7
7
|
"aws-sdk": "^2.1200.0",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"uuid": "^9.0.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@friggframework/eslint-config": "2.0.0--canary.419.
|
|
26
|
-
"@friggframework/prettier-config": "2.0.0--canary.419.
|
|
27
|
-
"@friggframework/test": "2.0.0--canary.419.
|
|
25
|
+
"@friggframework/eslint-config": "2.0.0--canary.419.e82b061.0",
|
|
26
|
+
"@friggframework/prettier-config": "2.0.0--canary.419.e82b061.0",
|
|
27
|
+
"@friggframework/test": "2.0.0--canary.419.e82b061.0",
|
|
28
28
|
"@types/lodash": "4.17.15",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
30
30
|
"chai": "^4.3.6",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "e82b061425a3503af2280f0704c34934f3237c35"
|
|
60
60
|
}
|