feat(api-watermark): 水印接口优化
This commit is contained in:
@@ -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',
|
||||
),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user