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:
@@ -43,6 +43,7 @@ const nextConfig: NextConfig = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
turbopack: {
|
turbopack: {
|
||||||
|
root: process.cwd(),
|
||||||
rules: {
|
rules: {
|
||||||
'*.sql': ['raw'],
|
'*.sql': ['raw'],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,8 +4,9 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --turbopack",
|
"dev": "next dev --turbopack",
|
||||||
"build": "next build --turbopack",
|
"build": "prisma generate && next build --turbopack",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
|
"postinstall": "prisma generate",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
"backup:create": "pnpm tsx scripts/backup-manager.ts create",
|
"backup:create": "pnpm tsx scripts/backup-manager.ts create",
|
||||||
"backup:list": "pnpm tsx scripts/backup-manager.ts list",
|
"backup:list": "pnpm tsx scripts/backup-manager.ts list",
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ OPTIONS:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async showConfig(): Promise<void> {
|
private async showConfig(): Promise<void> {
|
||||||
const config = backupService.getConfig();
|
const config = await backupService.getConfig();
|
||||||
const status = backupScheduler.getStatus();
|
const status = backupScheduler.getStatus();
|
||||||
|
|
||||||
console.log('⚙️ Configuration des sauvegardes:\n');
|
console.log('⚙️ Configuration des sauvegardes:\n');
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export async function GET(request: NextRequest) {
|
|||||||
console.log('🔄 API GET /api/backups called');
|
console.log('🔄 API GET /api/backups called');
|
||||||
|
|
||||||
// Test de la configuration d'abord
|
// Test de la configuration d'abord
|
||||||
const config = backupService.getConfig();
|
const config = await backupService.getConfig();
|
||||||
console.log('✅ Config loaded:', config);
|
console.log('✅ Config loaded:', config);
|
||||||
|
|
||||||
// Test du scheduler
|
// Test du scheduler
|
||||||
@@ -111,7 +111,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: 'Configuration updated',
|
message: 'Configuration updated',
|
||||||
data: backupService.getConfig(),
|
data: await backupService.getConfig(),
|
||||||
});
|
});
|
||||||
|
|
||||||
case 'scheduler':
|
case 'scheduler':
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ export const metadata: Metadata = {
|
|||||||
description: 'Tour de controle (Kanban, tache, daily, ...)',
|
description: 'Tour de controle (Kanban, tache, daily, ...)',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Force dynamic rendering (no static generation)
|
||||||
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
export default async function RootLayout({
|
export default async function RootLayout({
|
||||||
children,
|
children,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export default async function AdvancedSettingsPage() {
|
|||||||
// Compose backup data like the API does
|
// Compose backup data like the API does
|
||||||
const backups = await backupService.listBackups();
|
const backups = await backupService.listBackups();
|
||||||
const schedulerStatus = backupScheduler.getStatus();
|
const schedulerStatus = backupScheduler.getStatus();
|
||||||
const config = backupService.getConfig();
|
const config = await backupService.getConfig();
|
||||||
|
|
||||||
const backupData = {
|
const backupData = {
|
||||||
backups,
|
backups,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export default async function BackupSettingsPage() {
|
|||||||
// Fetch data server-side
|
// Fetch data server-side
|
||||||
const backups = await backupService.listBackups();
|
const backups = await backupService.listBackups();
|
||||||
const schedulerStatus = backupScheduler.getStatus();
|
const schedulerStatus = backupScheduler.getStatus();
|
||||||
const config = backupService.getConfig();
|
const config = await backupService.getConfig();
|
||||||
const backupStats = await backupService.getBackupStats(30);
|
const backupStats = await backupService.getBackupStats(30);
|
||||||
|
|
||||||
const initialData = {
|
const initialData = {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export class BackupScheduler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = backupService.getConfig();
|
const config = backupService.getConfigSync();
|
||||||
|
|
||||||
if (!config.enabled) {
|
if (!config.enabled) {
|
||||||
console.log('📋 Automatic backups are disabled');
|
console.log('📋 Automatic backups are disabled');
|
||||||
@@ -104,7 +104,7 @@ export class BackupScheduler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = backupService.getConfig();
|
const config = backupService.getConfigSync();
|
||||||
const intervalMs = this.getIntervalMs(config.interval);
|
const intervalMs = this.getIntervalMs(config.interval);
|
||||||
|
|
||||||
return addMinutes(getToday(), Math.floor(intervalMs / (1000 * 60)));
|
return addMinutes(getToday(), Math.floor(intervalMs / (1000 * 60)));
|
||||||
@@ -114,7 +114,7 @@ export class BackupScheduler {
|
|||||||
* Obtient les stats du planificateur
|
* Obtient les stats du planificateur
|
||||||
*/
|
*/
|
||||||
getStatus() {
|
getStatus() {
|
||||||
const config = backupService.getConfig();
|
const config = backupService.getConfigSync();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isRunning: this.isRunning,
|
isRunning: this.isRunning,
|
||||||
|
|||||||
@@ -41,19 +41,22 @@ export class BackupService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private config: BackupConfig;
|
private config: BackupConfig;
|
||||||
|
private configLoaded: boolean = false;
|
||||||
|
|
||||||
constructor(config?: Partial<BackupConfig>) {
|
constructor(config?: Partial<BackupConfig>) {
|
||||||
this.config = { ...this.defaultConfig, ...config };
|
this.config = { ...this.defaultConfig, ...config };
|
||||||
// Charger la config depuis la DB de manière asynchrone
|
// Ne pas charger la config depuis la DB dans le constructeur
|
||||||
this.loadConfigFromDB().catch(() => {
|
// pour éviter les erreurs pendant le build
|
||||||
// Ignorer les erreurs de chargement initial
|
// 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> {
|
private async loadConfigFromDB(): Promise<void> {
|
||||||
|
if (this.configLoaded) {
|
||||||
|
return; // Déjà chargé
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// Pour le service de backup, on utilise un userId par défaut
|
// Pour le service de backup, on utilise un userId par défaut
|
||||||
// car il n'a pas accès à la session
|
// car il n'a pas accès à la session
|
||||||
@@ -70,11 +73,14 @@ export class BackupService {
|
|||||||
this.config = { ...this.defaultConfig, ...backupConfig };
|
this.config = { ...this.defaultConfig, ...backupConfig };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.configLoaded = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(
|
console.warn(
|
||||||
'Could not load backup config from DB, using defaults:',
|
'Could not load backup config from DB, using defaults:',
|
||||||
error
|
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
|
// Retourner une config avec le chemin à jour
|
||||||
return {
|
return {
|
||||||
...this.config,
|
...this.config,
|
||||||
|
|||||||
Reference in New Issue
Block a user