22 lines
637 B
TypeScript
22 lines
637 B
TypeScript
import { syncCardsWithDatabase } from '../services/cardSync.service'
|
|
|
|
export default defineNitroPlugin(async (nitroApp) => {
|
|
const config = useRuntimeConfig()
|
|
const folderPath = config.pathFiles || process.env.PATH_FILES
|
|
|
|
if (!folderPath) {
|
|
console.warn('⚠️ PATH_FILES non configuré')
|
|
return
|
|
}
|
|
|
|
// Sync au démarrage
|
|
console.log('🚀 Synchronisation initiale au démarrage...')
|
|
|
|
try {
|
|
const result = await syncCardsWithDatabase(folderPath)
|
|
console.log('✅ Synchronisation initiale terminée:', result)
|
|
} catch (error: any) {
|
|
console.error('❌ Erreur lors de la sync initiale:', error)
|
|
}
|
|
})
|