chore: update configuration and improve backup service handling
- Added root path configuration for turbopack in next.config.ts. - Updated build script in package.json to include Prisma generation. - Changed backup service methods to use synchronous config retrieval where appropriate, improving performance and avoiding async issues. - Ensured dynamic rendering in layout.tsx for better page performance.
This commit is contained in:
@@ -30,7 +30,7 @@ export async function GET(request: NextRequest) {
|
||||
console.log('🔄 API GET /api/backups called');
|
||||
|
||||
// Test de la configuration d'abord
|
||||
const config = backupService.getConfig();
|
||||
const config = await backupService.getConfig();
|
||||
console.log('✅ Config loaded:', config);
|
||||
|
||||
// Test du scheduler
|
||||
@@ -111,7 +111,7 @@ export async function POST(request: NextRequest) {
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: 'Configuration updated',
|
||||
data: backupService.getConfig(),
|
||||
data: await backupService.getConfig(),
|
||||
});
|
||||
|
||||
case 'scheduler':
|
||||
|
||||
@@ -30,6 +30,9 @@ export const metadata: Metadata = {
|
||||
description: 'Tour de controle (Kanban, tache, daily, ...)',
|
||||
};
|
||||
|
||||
// Force dynamic rendering (no static generation)
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
|
||||
@@ -37,7 +37,7 @@ export default async function AdvancedSettingsPage() {
|
||||
// Compose backup data like the API does
|
||||
const backups = await backupService.listBackups();
|
||||
const schedulerStatus = backupScheduler.getStatus();
|
||||
const config = backupService.getConfig();
|
||||
const config = await backupService.getConfig();
|
||||
|
||||
const backupData = {
|
||||
backups,
|
||||
|
||||
@@ -9,7 +9,7 @@ export default async function BackupSettingsPage() {
|
||||
// Fetch data server-side
|
||||
const backups = await backupService.listBackups();
|
||||
const schedulerStatus = backupScheduler.getStatus();
|
||||
const config = backupService.getConfig();
|
||||
const config = await backupService.getConfig();
|
||||
const backupStats = await backupService.getBackupStats(30);
|
||||
|
||||
const initialData = {
|
||||
|
||||
@@ -14,7 +14,7 @@ export class BackupScheduler {
|
||||
return;
|
||||
}
|
||||
|
||||
const config = backupService.getConfig();
|
||||
const config = backupService.getConfigSync();
|
||||
|
||||
if (!config.enabled) {
|
||||
console.log('📋 Automatic backups are disabled');
|
||||
@@ -104,7 +104,7 @@ export class BackupScheduler {
|
||||
return null;
|
||||
}
|
||||
|
||||
const config = backupService.getConfig();
|
||||
const config = backupService.getConfigSync();
|
||||
const intervalMs = this.getIntervalMs(config.interval);
|
||||
|
||||
return addMinutes(getToday(), Math.floor(intervalMs / (1000 * 60)));
|
||||
@@ -114,7 +114,7 @@ export class BackupScheduler {
|
||||
* Obtient les stats du planificateur
|
||||
*/
|
||||
getStatus() {
|
||||
const config = backupService.getConfig();
|
||||
const config = backupService.getConfigSync();
|
||||
|
||||
return {
|
||||
isRunning: this.isRunning,
|
||||
|
||||
@@ -41,19 +41,22 @@ export class BackupService {
|
||||
}
|
||||
|
||||
private config: BackupConfig;
|
||||
private configLoaded: boolean = false;
|
||||
|
||||
constructor(config?: Partial<BackupConfig>) {
|
||||
this.config = { ...this.defaultConfig, ...config };
|
||||
// Charger la config depuis la DB de manière asynchrone
|
||||
this.loadConfigFromDB().catch(() => {
|
||||
// Ignorer les erreurs de chargement initial
|
||||
});
|
||||
// Ne pas charger la config depuis la DB dans le constructeur
|
||||
// pour éviter les erreurs pendant le build
|
||||
// La config sera chargée de manière lazy quand nécessaire
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge la configuration depuis la base de données
|
||||
* Charge la configuration depuis la base de données (lazy loading)
|
||||
*/
|
||||
private async loadConfigFromDB(): Promise<void> {
|
||||
if (this.configLoaded) {
|
||||
return; // Déjà chargé
|
||||
}
|
||||
try {
|
||||
// Pour le service de backup, on utilise un userId par défaut
|
||||
// car il n'a pas accès à la session
|
||||
@@ -70,11 +73,14 @@ export class BackupService {
|
||||
this.config = { ...this.defaultConfig, ...backupConfig };
|
||||
}
|
||||
}
|
||||
this.configLoaded = true;
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
'Could not load backup config from DB, using defaults:',
|
||||
error
|
||||
);
|
||||
// Marquer comme chargé même en cas d'erreur pour éviter de réessayer
|
||||
this.configLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,9 +599,23 @@ export class BackupService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtient la configuration actuelle
|
||||
* Obtient la configuration actuelle (synchrone)
|
||||
* Retourne la config par défaut si elle n'a pas encore été chargée depuis la DB
|
||||
*/
|
||||
getConfig(): BackupConfig {
|
||||
getConfigSync(): BackupConfig {
|
||||
return {
|
||||
...this.config,
|
||||
backupPath: this.getCurrentBackupPath(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtient la configuration actuelle
|
||||
* Charge la config depuis la DB si ce n'est pas déjà fait
|
||||
*/
|
||||
async getConfig(): Promise<BackupConfig> {
|
||||
// Charger la config depuis la DB si ce n'est pas déjà fait
|
||||
await this.loadConfigFromDB();
|
||||
// Retourner une config avec le chemin à jour
|
||||
return {
|
||||
...this.config,
|
||||
|
||||
Reference in New Issue
Block a user