* update * cleanup * fixing linting and tests errors * Refactor API Parameter Handling and Update Email Transport ✅ Updated API Route Parameters: - Changed parameter type from `{ id: string }` to `Promise<{ id: string }>` in PUT and DELETE methods for better async handling. ✅ Fixed Email Transport Creation: - Updated `nodemailer.createTransporter` to `nodemailer.createTransport` for correct transport configuration. ✅ Refactored AnalyticsDashboard Component: - Changed export from default to named export for better modularity. ✅ Enhanced Email Responder Toast: - Updated toast structure to include additional properties for better user feedback. 🎯 Overall Improvements: - Improved async handling in API routes. - Ensured correct usage of nodemailer. - Enhanced component exports and user notifications.
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
const { exec } = require('child_process');
|
|
|
|
console.log('🗄️ Setting up database...');
|
|
|
|
// Set environment variables for development
|
|
process.env.DATABASE_URL = 'postgresql://portfolio_user:portfolio_dev_pass@localhost:5432/portfolio_dev?schema=public';
|
|
|
|
// Function to run command and return promise
|
|
function runCommand(command) {
|
|
return new Promise((resolve, reject) => {
|
|
console.log(`Running: ${command}`);
|
|
exec(command, (error, stdout, stderr) => {
|
|
if (error) {
|
|
console.error(`Error: ${error.message}`);
|
|
reject(error);
|
|
return;
|
|
}
|
|
if (stderr) {
|
|
console.log(`Stderr: ${stderr}`);
|
|
}
|
|
console.log(`Output: ${stdout}`);
|
|
resolve(stdout);
|
|
});
|
|
});
|
|
}
|
|
|
|
async function setupDatabase() {
|
|
try {
|
|
console.log('📦 Generating Prisma client...');
|
|
await runCommand('npx prisma generate');
|
|
|
|
console.log('🔄 Pushing database schema...');
|
|
await runCommand('npx prisma db push');
|
|
|
|
console.log('🌱 Seeding database...');
|
|
await runCommand('npx prisma db seed');
|
|
|
|
console.log('✅ Database setup complete!');
|
|
console.log('🚀 You can now run: npm run dev');
|
|
|
|
} catch (error) {
|
|
console.error('❌ Database setup failed:', error.message);
|
|
console.log('💡 Make sure PostgreSQL is running on localhost:5432');
|
|
console.log('💡 Try: docker-compose -f docker-compose.dev.minimal.yml up -d');
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
setupDatabase();
|