feat(api-watermark): 水印接口优化

This commit is contained in:
R524809
2026-09-04 15:58:53 +08:00
parent 009082d0f4
commit f635359216
8 changed files with 7350 additions and 5436 deletions
+24 -1
View File
@@ -2,7 +2,11 @@ import { existsSync } from 'node:fs';
import { resolve } from 'node:path';
import { loadEnvFile } from 'node:process';
for (const directory of [process.cwd(), resolve(process.cwd(), '..'), resolve(process.cwd(), '../..')]) {
for (const directory of [
process.cwd(),
resolve(process.cwd(), '..'),
resolve(process.cwd(), '../..'),
]) {
const path = resolve(directory, '.env');
if (existsSync(path)) {
loadEnvFile(path);
@@ -16,8 +20,27 @@ function required(name: string): string {
return value;
}
function objectStorageCredential(
accessKeyName: string,
localFallbackName: string,
): string {
return process.env[accessKeyName] || required(localFallbackName);
}
export const workerConfig = {
databaseUrl: required('DATABASE_URL'),
redisUrl: required('REDIS_URL'),
storeSecretEncryptionKey: required('STORE_SECRET_ENCRYPTION_KEY'),
objectStorageEndpoint:
process.env.OBJECT_STORAGE_ENDPOINT ?? 'http://localhost:9000',
objectStorageForcePathStyle:
(process.env.OBJECT_STORAGE_FORCE_PATH_STYLE ?? 'true') === 'true',
objectStorageAccessKey: objectStorageCredential(
'OBJECT_STORAGE_ACCESS_KEY',
'MINIO_ROOT_USER',
),
objectStorageSecretKey: objectStorageCredential(
'OBJECT_STORAGE_SECRET_KEY',
'MINIO_ROOT_PASSWORD',
),
};