try fix .env with NUXT_ prefix
All checks were successful
Deploy App / build (push) Successful in 49s
Deploy App / deploy (push) Successful in 22s

This commit is contained in:
valere
2026-02-10 18:44:00 +01:00
parent 08db4d7388
commit ffd5c5d7eb
10 changed files with 15 additions and 24 deletions

4
.env
View File

@@ -2,4 +2,6 @@ DOMAIN=evilspins.com
PORT=7901 PORT=7901
PORT_EXPOSED=3000 PORT_EXPOSED=3000
NODE_ENV=production NODE_ENV=production
ENABLE_WATCHER=true NUXT_PATH_DB=data/music.db
NUXT_URL_PREFIX=https://files.erudi.fr/music/
NUXT_PATH_FILES=mnt/media/files/music

View File

@@ -6,6 +6,6 @@ export default defineConfig({
schema: './server/db/schema.ts', schema: './server/db/schema.ts',
dialect: 'sqlite', dialect: 'sqlite',
dbCredentials: { dbCredentials: {
url: process.env.PATH_DB! url: process.env.NUXT_PATH_DB!
} }
}) })

View File

@@ -4,11 +4,6 @@ import tsconfigPaths from 'vite-tsconfig-paths'
const isProd = process.env.NODE_ENV === 'production' const isProd = process.env.NODE_ENV === 'production'
export default defineNuxtConfig({ export default defineNuxtConfig({
runtimeConfig: {
PATH_FILES: 'mnt/media/files/music',
PATH_DB: 'data/music.db',
URL_PREFIX: 'https://files.erudi.fr/music/'
},
nitro: { nitro: {
experimental: { experimental: {
tasks: true tasks: true

View File

@@ -2,12 +2,12 @@ import { syncCardsWithDatabase } from '../services/cardSync.service'
export default defineEventHandler(async (event) => { export default defineEventHandler(async (event) => {
const config = useRuntimeConfig() const config = useRuntimeConfig()
const folderPath = config.PATH_FILES const folderPath = process.env.NUXT_PATH_FILES
if (!folderPath) { if (!folderPath) {
throw createError({ throw createError({
statusCode: 500, statusCode: 500,
message: 'PATH_FILES not configured' message: 'NUXT_PATH_FILES not configured'
}) })
} }

View File

@@ -1,8 +1,7 @@
import { syncCardsWithDatabase } from '../../services/cardSync.service' import { syncCardsWithDatabase } from '../../services/cardSync.service'
export default defineEventHandler(async (event) => { export default defineEventHandler(async (event) => {
const config = useRuntimeConfig() const folderPath = process.env.NUXT_PATH_FILES
const folderPath = config.PATH_FILES
try { try {
const result = await syncCardsWithDatabase(folderPath) const result = await syncCardsWithDatabase(folderPath)

View File

@@ -1,8 +1,7 @@
import { scanMusicFolder } from '../../utils/fileScanner' import { scanMusicFolder } from '../../utils/fileScanner'
export default defineEventHandler(async (event) => { export default defineEventHandler(async (event) => {
const config = useRuntimeConfig() const folderPath = process.env.NUXT_PATH_FILES
const folderPath = config.PATH_FILES
try { try {
// Test 1: Vérifier que le dossier existe // Test 1: Vérifier que le dossier existe

View File

@@ -6,11 +6,10 @@ let _db: ReturnType<typeof drizzle> | null = null
export function useDB() { export function useDB() {
if (_db) return _db if (_db) return _db
const config = useRuntimeConfig() let dbPath = process.env.NUXT_PATH_DB
let dbPath = config.PATH_DB
if (!dbPath) { if (!dbPath) {
throw new Error('PATH_DB is not configured') throw new Error('NUXT_PATH_DB is not configured')
} }
// Convertir le chemin en URL file:// si ce n'est pas déjà une URL // Convertir le chemin en URL file:// si ce n'est pas déjà une URL

View File

@@ -1,11 +1,10 @@
import { syncCardsWithDatabase } from '../services/cardSync.service' import { syncCardsWithDatabase } from '../services/cardSync.service'
export default defineNitroPlugin(async (nitroApp) => { export default defineNitroPlugin(async (nitroApp) => {
const config = useRuntimeConfig() const folderPath = process.env.NUXT_PATH_FILES
const folderPath = config.PATH_FILES
if (!folderPath) { if (!folderPath) {
console.warn('⚠️ PATH_FILES non configuré') console.warn('⚠️ NUXT_PATH_FILES non configuré')
return return
} }

View File

@@ -6,8 +6,7 @@ export default defineTask({
description: 'Synchronise les tracks avec le système de fichiers' description: 'Synchronise les tracks avec le système de fichiers'
}, },
async run() { async run() {
const config = useRuntimeConfig() const folderPath = process.env.NUXT_PATH_FILES
const folderPath = config.PATH_FILES
console.log('⏰ [TASK] Démarrage de la synchronisation planifiée...') console.log('⏰ [TASK] Démarrage de la synchronisation planifiée...')

View File

@@ -10,7 +10,6 @@ const listImageExts = ['.jpg', '.jpeg', '.webp']
export async function scanMusicFolder(folderPath: string): Promise<Card[]> { export async function scanMusicFolder(folderPath: string): Promise<Card[]> {
try { try {
const config = useRuntimeConfig()
const files = await readdir(folderPath) const files = await readdir(folderPath)
const cardMap = new Map<string, Card>() const cardMap = new Map<string, Card>()
@@ -31,14 +30,14 @@ export async function scanMusicFolder(folderPath: string): Promise<Card[]> {
for (const imgExt of listImageExts) { for (const imgExt of listImageExts) {
const potentialImage = baseName + imgExt const potentialImage = baseName + imgExt
if (files.includes(potentialImage)) { if (files.includes(potentialImage)) {
imageUrl = config.URL_PREFIX + baseName + imgExt imageUrl = process.env.NUXT_URL_PREFIX + baseName + imgExt
break break
} }
} }
cardMap.set(parsed.esid, { cardMap.set(parsed.esid, {
...parsed, ...parsed,
url_audio: config.URL_PREFIX + baseName + ext, url_audio: process.env.NUXT_URL_PREFIX + baseName + ext,
url_image: imageUrl, url_image: imageUrl,
suit: parsed.suit, suit: parsed.suit,
rank: parsed.rank rank: parsed.rank