Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bim-review-coordinator/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface CoordinatorConfig {
userAuthProvider: string;
// fast-ifc-link-demo-loop §2.5:同步下載 IFC + viewer_url 組合 + shared volume 路徑
ifcDownloadTimeoutSeconds: number; // POST /api/external/ifc-ready 同步下載 timeout
storageRoot: string; // container view storage root,寫入用
storageRoot: string; // coordinator 寫入路徑;docker compose 顯式設 /workspace/storage,host-native 預設 <cwd>/storage
storageHostRoot: string; // host view storage root,寫進 dispatch payload host_local_path
publicHost: string; // viewer_url 用的對外 host(coordinator 對 LAN IP);default 127.0.0.1
}
Expand Down Expand Up @@ -203,7 +203,7 @@ export function loadConfig(overrides: Partial<CoordinatorConfig> = {}): Coordina
userAuthProvider: process.env.USER_AUTH_PROVIDER || "local-dev",
// fast-ifc-link-demo-loop §2.5:
ifcDownloadTimeoutSeconds: numberFromEnv("IFC_DOWNLOAD_TIMEOUT_SECONDS", 600),
storageRoot: process.env.STORAGE_ROOT || "/workspace/storage",
storageRoot: process.env.STORAGE_ROOT || path.join(cwd, "storage"),
storageHostRoot:
process.env.STORAGE_HOST_ROOT || process.env.RUNTIME_STORAGE_ROOT || path.join(cwd, "storage"),
publicHost: process.env.PUBLIC_HOST || "127.0.0.1",
Expand Down
2 changes: 1 addition & 1 deletion bim-review-coordinator/src/services/ifcDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import path from "node:path";
*/

export interface IfcDownloadOptions {
/** Container view storage root,coordinator 寫入用(預設 `/workspace/storage`)。 */
/** Storage root,coordinator 寫入用。docker compose:`/workspace/storage`(env 顯式設);host-native:預設 `<cwd>/storage`。 */
storageRoot: string;
/**
* Host view storage root,寫進回傳 host_local_path 供 streaming-server 讀取。
Expand Down
22 changes: 22 additions & 0 deletions bim-review-coordinator/tests/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { loadConfig } from "../src/config.js";

const originalConversionApiBase = process.env.CONVERSION_API_BASE;
const originalStreamingConversionApiBase = process.env.STREAMING_CONVERSION_API_BASE;
const originalKitStreamServer = process.env.KIT_STREAM_SERVER;
const originalKitMediaServer = process.env.KIT_MEDIA_SERVER;
const originalStorageRoot = process.env.STORAGE_ROOT;

afterEach(() => {
if (originalConversionApiBase === undefined) {
Expand All @@ -30,6 +32,12 @@ afterEach(() => {
} else {
process.env.KIT_MEDIA_SERVER = originalKitMediaServer;
}

if (originalStorageRoot === undefined) {
delete process.env.STORAGE_ROOT;
} else {
process.env.STORAGE_ROOT = originalStorageRoot;
}
});

describe("loadConfig conversion API base", () => {
Expand Down Expand Up @@ -78,3 +86,17 @@ describe("loadConfig Kit endpoint", () => {
expect(config.kitMediaServer.length).toBeGreaterThan(0);
});
});

describe("loadConfig storageRoot fallback", () => {
it("falls back to <cwd>/storage when STORAGE_ROOT is not set (host-native default)", () => {
delete process.env.STORAGE_ROOT;

expect(loadConfig().storageRoot).toBe(path.join(process.cwd(), "storage"));
});

it("respects explicit STORAGE_ROOT env (docker compose still sets /workspace/storage)", () => {
process.env.STORAGE_ROOT = "/workspace/storage";

expect(loadConfig().storageRoot).toBe("/workspace/storage");
});
});