@hotmeshio/long-tail 0.4.9 → 0.4.10
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/build/start/config.js +26 -15
- package/package.json +1 -1
package/build/start/config.js
CHANGED
|
@@ -37,33 +37,44 @@ exports.applyDatabaseConfig = applyDatabaseConfig;
|
|
|
37
37
|
exports.applyServerAuthConfig = applyServerAuthConfig;
|
|
38
38
|
const config_1 = require("../modules/config");
|
|
39
39
|
const auth_1 = require("../modules/auth");
|
|
40
|
+
const logger_1 = require("../lib/logger");
|
|
40
41
|
/**
|
|
41
42
|
* Apply database connection settings from the startup config
|
|
42
43
|
* to the shared postgres_options object.
|
|
43
44
|
*/
|
|
44
45
|
function applyDatabaseConfig(db) {
|
|
45
46
|
if (db.connectionString) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
// Infer SSL from sslmode in connection string when not explicitly provided
|
|
48
|
+
if (!db.ssl) {
|
|
49
|
+
try {
|
|
50
|
+
const sslmode = new URL(db.connectionString).searchParams.get('sslmode');
|
|
51
|
+
if (sslmode === 'require') {
|
|
52
|
+
config_1.postgres_options.ssl = { rejectUnauthorized: false };
|
|
53
|
+
logger_1.loggerRegistry.info('[long-tail] database SSL inferred from sslmode=require');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch { /* not a parseable URL — skip inference */ }
|
|
57
|
+
}
|
|
58
|
+
// Clear individual fields — connectionString takes precedence.
|
|
59
|
+
// Delete stale keys so pg doesn't see conflicting host/port/etc.
|
|
60
|
+
delete config_1.postgres_options.host;
|
|
61
|
+
delete config_1.postgres_options.port;
|
|
62
|
+
delete config_1.postgres_options.user;
|
|
63
|
+
delete config_1.postgres_options.password;
|
|
64
|
+
delete config_1.postgres_options.database;
|
|
65
|
+
config_1.postgres_options.connectionString = db.connectionString;
|
|
54
66
|
}
|
|
55
67
|
else {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
database: db.database ?? config_1.postgres_options.database,
|
|
62
|
-
});
|
|
68
|
+
config_1.postgres_options.host = db.host ?? config_1.postgres_options.host;
|
|
69
|
+
config_1.postgres_options.port = db.port ?? config_1.postgres_options.port;
|
|
70
|
+
config_1.postgres_options.user = db.user ?? config_1.postgres_options.user;
|
|
71
|
+
config_1.postgres_options.password = db.password ?? config_1.postgres_options.password;
|
|
72
|
+
config_1.postgres_options.database = db.database ?? config_1.postgres_options.database;
|
|
63
73
|
}
|
|
64
74
|
// SSL passthrough — applies to both connectionString and individual-field modes
|
|
65
75
|
if (db.ssl !== undefined) {
|
|
66
76
|
config_1.postgres_options.ssl = db.ssl;
|
|
77
|
+
logger_1.loggerRegistry.info(`[long-tail] database SSL configured: ${typeof db.ssl === 'object' ? JSON.stringify(db.ssl) : db.ssl}`);
|
|
67
78
|
}
|
|
68
79
|
}
|
|
69
80
|
/**
|
package/package.json
CHANGED