const dotenv = require('dotenv');
const path = require('path');

// 加载 .env 文件
const result = dotenv.config({
    path: path.resolve(__dirname, '../.env')
});

if (result.error) {
    console.error('Error loading .env file:', result.error);
}

const config = {
    accessKeyId: process.env.OSS_ACCESS_KEY_ID,
    accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET,
    bucket: process.env.OSS_BUCKET,
    endpoint: process.env.OSS_ENDPOINT
};

// 验证配置
console.log('Current environment variables:', {
    NODE_ENV: process.env.NODE_ENV,
    PWD: process.env.PWD
});

console.log('OSS Config:', {
    accessKeyId: config.accessKeyId ? '***' : undefined,
    accessKeySecret: config.accessKeySecret ? '***' : undefined,
    bucket: config.bucket,
    endpoint: config.endpoint
});

Object.entries(config).forEach(([key, value]) => {
    if (!value) {
        console.error(`Missing OSS configuration: ${key}`);
    }
});

module.exports = config; 