Phase 2 Complete - Backend Core Logic New Components: - DeletionLogRepository: CRUD for deletion audit trail - GroupCleanupService: Core cleanup logic - findGroupsForDeletion() - finds unapproved groups older than 7 days - deleteGroupCompletely() - DB + file deletion - deletePhysicalFiles() - removes images & previews - logDeletion() - creates audit log entry - getDaysUntilDeletion() - calculates remaining days - performScheduledCleanup() - main cleanup orchestrator - SchedulerService: Cron job management - Daily cleanup at 10:00 AM (Europe/Berlin) - Manual trigger for development GroupRepository Extensions: - findUnapprovedGroupsOlderThan(days) - deleteGroupCompletely(groupId) - getGroupStatistics(groupId) Dependencies: - node-cron ^3.0.3 Integration: - Scheduler auto-starts with server (server.js) - Comprehensive logging for all operations Tasks completed: ✅ 2.3, ✅ 2.4, ✅ 2.5
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
const express = require('express');
|
|
const initiateResources = require('./utils/initiate-resources');
|
|
const dbManager = require('./database/DatabaseManager');
|
|
const SchedulerService = require('./services/SchedulerService');
|
|
|
|
class Server {
|
|
_port;
|
|
_app;
|
|
|
|
constructor(port) {
|
|
this._port = port;
|
|
this._app = express();
|
|
}
|
|
|
|
async start() {
|
|
try {
|
|
// Initialisiere Datenbank
|
|
console.log('🔄 Initialisiere Datenbank...');
|
|
await dbManager.initialize();
|
|
console.log('✓ Datenbank bereit');
|
|
|
|
// Starte Express Server
|
|
initiateResources(this._app);
|
|
this._app.use('/upload', express.static( __dirname + '/upload'));
|
|
this._app.listen(this._port, () => {
|
|
console.log(`✅ Server läuft auf Port ${this._port}`);
|
|
console.log(`📊 SQLite Datenbank aktiv`);
|
|
|
|
// Starte Scheduler für automatisches Cleanup
|
|
SchedulerService.start();
|
|
});
|
|
} catch (error) {
|
|
console.error('💥 Fehler beim Serverstart:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Server; |