使用外部数据库

This commit is contained in:
Julian Freeman
2026-01-05 12:22:01 -04:00
parent 4581297dac
commit f549059e47
9 changed files with 170 additions and 78 deletions

37
scripts/generate-env.js Normal file
View File

@@ -0,0 +1,37 @@
const fs = require('fs');
const path = require('path');
const envPath = path.join(__dirname, '..', '.env');
const outputPath = path.join(__dirname, '..', 'env.js');
try {
let envContent = '';
if (fs.existsSync(envPath)) {
envContent = fs.readFileSync(envPath, 'utf8');
}
const envVars = {};
envContent.split('\n').forEach(line => {
const match = line.match(/^\s*([\w_]+)\s*=\s*(.*)?\s*$/);
if (match) {
const key = match[1];
let value = match[2] || '';
// Remove quotes if present
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'" ) && value.endsWith("'" ))) {
value = value.slice(1, -1);
}
envVars[key] = value;
}
});
const fileContent = `// Auto-generated by scripts/generate-env.js
const ENV_SECRETS = ${JSON.stringify(envVars, null, 4)};
`;
fs.writeFileSync(outputPath, fileContent);
console.log('Successfully generated env.js');
} catch (err) {
console.error('Error generating env.js:', err);
process.exit(1);
}