Fix backend 500 errors for event creation and system version
- Fix system version endpoint to read package.json using fs instead of require - Prevents MODULE_NOT_FOUND error in Docker container - Uses path.join to find package.json reliably - Fix event creation email queue error - Change email_type from 'creation' to 'gallery_created' to match template key - Update email_data to include all required template variables - Added missing created_at and updated_at columns to email_queue table - Fix file watcher duplicate photo insertion - Add check to prevent re-inserting existing photos on backend restart These fixes resolve: 1. 500 error when accessing /api/admin/system/version 2. 500 error when creating new events 3. Email queue processing errors 4. Photo duplication issue 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -10,10 +10,18 @@ const router = express.Router();
|
||||
router.get('/version', adminAuth, async (req, res) => {
|
||||
try {
|
||||
// Read backend version from package.json
|
||||
const packageJson = require('../../../package.json');
|
||||
let backendVersion = '1.0.0';
|
||||
try {
|
||||
const packagePath = path.join(__dirname, '../../package.json');
|
||||
const packageContent = await fs.readFile(packagePath, 'utf8');
|
||||
const packageJson = JSON.parse(packageContent);
|
||||
backendVersion = packageJson.version || '1.0.0';
|
||||
} catch (err) {
|
||||
console.error('Could not read package.json:', err);
|
||||
}
|
||||
|
||||
res.json({
|
||||
backend: packageJson.version,
|
||||
backend: backendVersion,
|
||||
frontend: '1.0.0', // This will be set by frontend
|
||||
node: process.version,
|
||||
environment: process.env.NODE_ENV || 'production'
|
||||
|
||||
Reference in New Issue
Block a user