Implement Phase 2 asset storage pipeline

This commit is contained in:
Media
2026-08-16 19:59:10 -05:00
parent eb19675a5c
commit 722c6cf77d
29 changed files with 5059 additions and 16 deletions
+41
View File
@@ -32,6 +32,14 @@ test("loadConfig validates and normalizes the supported environment", () => {
assert.equal(config.timeZone, "America/Chicago");
assert.equal(config.storage.endpoint, "http://seaweedfs:8333");
assert.equal(config.storage.forcePathStyle, true);
assert.equal(config.storage.healthProbeIntervalMs, 30_000);
assert.equal(config.storage.connectionTimeoutMs, 2_000);
assert.equal(config.storage.requestTimeoutMs, 5_000);
assert.equal(config.storage.maxAttempts, 2);
assert.equal(config.processing.tempDirectory, "/tmp/announcements-uploads");
assert.equal(config.processing.maxFileBytes, 25 * 1024 * 1024);
assert.equal(config.processing.maxFiles, 20);
assert.equal(config.processing.maxInputPixels, 40_000_000);
});
test("production requires private S3 credentials", () => {
@@ -65,10 +73,42 @@ test("loadConfig rejects invalid typed values", () => {
() => loadConfig(validEnvironment({ S3_FORCE_PATH_STYLE: "sometimes" })),
/must be a boolean/,
);
assert.throws(
() => loadConfig(validEnvironment({ S3_HEALTH_PROBE_INTERVAL_MS: "999" })),
/S3_HEALTH_PROBE_INTERVAL_MS must be at least 1000/,
);
assert.throws(
() => loadConfig(validEnvironment({ S3_REQUEST_TIMEOUT_MS: "999" })),
/S3_REQUEST_TIMEOUT_MS must be at least 1000/,
);
assert.throws(
() => loadConfig(validEnvironment({ S3_CONNECT_TIMEOUT_MS: "249" })),
/S3_CONNECT_TIMEOUT_MS must be at least 250/,
);
assert.throws(
() => loadConfig(validEnvironment({ S3_MAX_ATTEMPTS: "6" })),
/S3_MAX_ATTEMPTS must be at most 5/,
);
assert.throws(
() => loadConfig(validEnvironment({ DATABASE_PATH: "relative.sqlite" })),
/must be an absolute path/,
);
assert.throws(
() => loadConfig(validEnvironment({ UPLOAD_TEMP_DIRECTORY: "relative" })),
/UPLOAD_TEMP_DIRECTORY must be an absolute path/,
);
assert.throws(
() => loadConfig(validEnvironment({ UPLOAD_MAX_FILE_BYTES: "0" })),
/UPLOAD_MAX_FILE_BYTES must be at least 1/,
);
assert.throws(
() => loadConfig(validEnvironment({ UPLOAD_MAX_FILES: "101" })),
/UPLOAD_MAX_FILES must be at most 100/,
);
assert.throws(
() => loadConfig(validEnvironment({ IMAGE_MAX_INPUT_PIXELS: "no-limit" })),
/IMAGE_MAX_INPUT_PIXELS must be an integer/,
);
});
test("redactedConfig never returns credentials, passwords, paths, or webhook URLs", () => {
@@ -83,5 +123,6 @@ test("redactedConfig never returns credentials, passwords, paths, or webhook URL
assert.doesNotMatch(serialized, /mqtt-password/);
assert.doesNotMatch(serialized, /webhook-secret/);
assert.doesNotMatch(serialized, /announcements\.sqlite/);
assert.doesNotMatch(serialized, /seaweedfs/);
assert.doesNotMatch(serialized, /home-assistant/);
});