arnacon-webrtc-service 0.1.1 → 0.1.2
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/package.json
CHANGED
|
@@ -151,7 +151,21 @@ const { WebSocket: WsWebSocket } = require("ws");
|
|
|
151
151
|
// ════════════════════════════════════════════════════════════
|
|
152
152
|
|
|
153
153
|
// ─── Load config from config.json + services/*.json ──────────
|
|
154
|
-
const
|
|
154
|
+
const PACKAGE_ROOT = path.resolve(__dirname, "..");
|
|
155
|
+
const CONFIG_OVERRIDE = process.env.WEBRTC_CONFIG_PATH || process.env.ARNACON_WEBRTC_CONFIG_PATH || "";
|
|
156
|
+
const CONFIG_PATH = CONFIG_OVERRIDE
|
|
157
|
+
? (path.isAbsolute(CONFIG_OVERRIDE) ? CONFIG_OVERRIDE : path.resolve(process.cwd(), CONFIG_OVERRIDE))
|
|
158
|
+
: path.join(PACKAGE_ROOT, "config.json");
|
|
159
|
+
const CONFIG_BASE_DIR = path.dirname(CONFIG_PATH);
|
|
160
|
+
const fullConfig = JSON.parse(fs.readFileSync(CONFIG_PATH, "utf8"));
|
|
161
|
+
|
|
162
|
+
function resolveRuntimePath(entryPath) {
|
|
163
|
+
if (!entryPath) return "";
|
|
164
|
+
if (path.isAbsolute(entryPath)) return entryPath;
|
|
165
|
+
const fromConfigDir = path.resolve(CONFIG_BASE_DIR, entryPath);
|
|
166
|
+
if (fs.existsSync(fromConfigDir)) return fromConfigDir;
|
|
167
|
+
return path.resolve(PACKAGE_ROOT, entryPath);
|
|
168
|
+
}
|
|
155
169
|
const deployEnv = process.env.DEPLOY_ENV || "development";
|
|
156
170
|
const envConfig = fullConfig[deployEnv] || {};
|
|
157
171
|
const commonConfig = envConfig.common || {};
|
|
@@ -159,8 +173,8 @@ const serviceRegistry = envConfig.services || {};
|
|
|
159
173
|
const loadedServices = {};
|
|
160
174
|
|
|
161
175
|
for (const [serviceId, serviceEntry] of Object.entries(serviceRegistry)) {
|
|
162
|
-
const serviceConfigPath =
|
|
163
|
-
const serviceModulePath =
|
|
176
|
+
const serviceConfigPath = resolveRuntimePath(serviceEntry.configPath);
|
|
177
|
+
const serviceModulePath = resolveRuntimePath(serviceEntry.modulePath);
|
|
164
178
|
const serviceConfigRoot = JSON.parse(fs.readFileSync(serviceConfigPath, "utf8"));
|
|
165
179
|
const serviceConfig = serviceConfigRoot[deployEnv];
|
|
166
180
|
if (!serviceConfig) {
|