test server NUXT_ env in nuxt config
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { syncCardsWithDatabase } from '../services/cardSync.service'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const folderPath = process.env.NUXT_PATH_FILES
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const folderPath = runtimeConfig.NUXT_PATH_FILES
|
||||
|
||||
if (!folderPath) {
|
||||
throw createError({
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { syncCardsWithDatabase } from '../../services/cardSync.service'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const folderPath = process.env.NUXT_PATH_FILES
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const folderPath = runtimeConfig.NUXT_PATH_FILES
|
||||
|
||||
try {
|
||||
const result = await syncCardsWithDatabase(folderPath)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { scanMusicFolder } from '../../utils/fileScanner'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const folderPath = process.env.NUXT_PATH_FILES
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const folderPath = runtimeConfig.NUXT_PATH_FILES
|
||||
|
||||
try {
|
||||
// Test 1: Vérifier que le dossier existe
|
||||
|
||||
@@ -6,11 +6,7 @@ let _db: ReturnType<typeof drizzle> | null = null
|
||||
export function useDB() {
|
||||
if (_db) return _db
|
||||
|
||||
let dbPath = process.env.NUXT_PATH_DB
|
||||
|
||||
if (!dbPath) {
|
||||
throw new Error('PATH_DB is not configured')
|
||||
}
|
||||
let dbPath = 'data/music.db'
|
||||
|
||||
// Convertir le chemin en URL file:// si ce n'est pas déjà une URL
|
||||
if (!dbPath.startsWith('file:') && !dbPath.startsWith('libsql:') && !dbPath.startsWith('http')) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { syncCardsWithDatabase } from '../services/cardSync.service'
|
||||
|
||||
export default defineNitroPlugin(async (nitroApp) => {
|
||||
const folderPath = process.env.NUXT_PATH_FILES
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const folderPath = runtimeConfig.NUXT_PATH_FILES
|
||||
|
||||
if (!folderPath) {
|
||||
console.warn('⚠️ NUXT_PATH_FILES non configuré')
|
||||
|
||||
@@ -6,8 +6,8 @@ export default defineTask({
|
||||
description: 'Synchronise les tracks avec le système de fichiers'
|
||||
},
|
||||
async run() {
|
||||
const config = useRuntimeConfig()
|
||||
const folderPath = process.env.NUXT_PATH_FILES
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const folderPath = runtimeConfig.NUXT_PATH_FILES
|
||||
|
||||
console.log('⏰ [TASK] Démarrage de la synchronisation planifiée...')
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ const listAudioExts = ['.mp3', '.opus', 'flac']
|
||||
const listImageExts = ['.jpg', '.jpeg', '.webp']
|
||||
|
||||
export async function scanMusicFolder(folderPath: string): Promise<Card[]> {
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const urlPrefix = runtimeConfig.NUXT_URL_PREFIX
|
||||
|
||||
try {
|
||||
const files = await readdir(folderPath)
|
||||
const cardMap = new Map<string, Card>()
|
||||
@@ -30,14 +33,14 @@ export async function scanMusicFolder(folderPath: string): Promise<Card[]> {
|
||||
for (const imgExt of listImageExts) {
|
||||
const potentialImage = baseName + imgExt
|
||||
if (files.includes(potentialImage)) {
|
||||
imageUrl = process.env.NUXT_URL_PREFIX + baseName + imgExt
|
||||
imageUrl = urlPrefix + baseName + imgExt
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
cardMap.set(parsed.esid, {
|
||||
...parsed,
|
||||
url_audio: process.env.NUXT_URL_PREFIX + baseName + ext,
|
||||
url_audio: urlPrefix + baseName + ext,
|
||||
url_image: imageUrl,
|
||||
suit: parsed.suit,
|
||||
rank: parsed.rank
|
||||
|
||||
Reference in New Issue
Block a user