Initial commit: Complete NodeJS-native setup

- Migrated from Python pre-commit to NodeJS-native solution
- Reorganized documentation structure
- Set up Husky + lint-staged for efficient pre-commit hooks
- Fixed Dockerfile healthcheck issue
- Added comprehensive documentation index
This commit is contained in:
William Valentin
2025-09-06 01:42:48 -07:00
commit e48adbcb00
159 changed files with 24405 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
#!/usr/bin/env node
// Production database seeder script
// This script seeds the production CouchDB with default admin user
import { readFileSync } from 'fs';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const projectDir = resolve(__dirname, '..');
console.log('🌱 Starting production database seeding...');
// Load environment variables from .env file if it exists
try {
const envFile = resolve(projectDir, '.env');
const envContent = readFileSync(envFile, 'utf8');
console.log('📄 Loading environment variables from .env file...');
envContent.split('\n').forEach(line => {
const trimmed = line.trim();
if (trimmed && !trimmed.startsWith('#') && trimmed.includes('=')) {
const [key, ...valueParts] = trimmed.split('=');
const value = valueParts.join('=');
if (!process.env[key]) {
process.env[key] = value;
}
}
});
} catch (error) {
console.log(
' No .env file found, using environment variables or defaults'
);
}
// Use environment variables with fallbacks
const COUCHDB_URL =
process.env.VITE_COUCHDB_URL ||
process.env.COUCHDB_URL ||
'http://localhost:5984';
const COUCHDB_USER =
process.env.VITE_COUCHDB_USER || process.env.COUCHDB_USER || 'admin';
const COUCHDB_PASSWORD =
process.env.VITE_COUCHDB_PASSWORD ||
process.env.COUCHDB_PASSWORD ||
'change-this-secure-password';
// Set environment variables for the seeder to use
process.env.VITE_COUCHDB_URL = COUCHDB_URL;
process.env.VITE_COUCHDB_USER = COUCHDB_USER;
process.env.VITE_COUCHDB_PASSWORD = COUCHDB_PASSWORD;
console.log('🔗 CouchDB Configuration:');
console.log(` URL: ${COUCHDB_URL}`);
console.log(` User: ${COUCHDB_USER}`);
console.log(` Password: ${'*'.repeat(COUCHDB_PASSWORD.length)}`);
// Validate required environment variables
if (!COUCHDB_URL || !COUCHDB_USER || !COUCHDB_PASSWORD) {
console.error('❌ Missing required environment variables:');
console.error(' VITE_COUCHDB_URL or COUCHDB_URL');
console.error(' VITE_COUCHDB_USER or COUCHDB_USER');
console.error(' VITE_COUCHDB_PASSWORD or COUCHDB_PASSWORD');
console.error('');
console.error('💡 Set these in your .env file or as environment variables');
process.exit(1);
}
async function seedDatabase() {
try {
// Import the seeder (this will use the production CouchDB due to env vars)
const { DatabaseSeeder } = await import('../services/database.seeder.ts');
// Wait a bit for databases to be initialized
console.log('⏳ Waiting for databases to initialize...');
await new Promise(resolve => setTimeout(resolve, 2000));
const seeder = new DatabaseSeeder();
console.log('📊 Seeding admin user...');
await seeder.seedDefaultAdmin();
console.log('🎉 Production database seeding completed successfully!');
console.log('🔐 You can now login with:');
console.log(' Email: admin@localhost');
console.log(' Password: change-this-secure-password');
process.exit(0);
} catch (error) {
console.error('❌ Seeding failed:', error);
process.exit(1);
}
}
seedDatabase();