diff --git a/.env.example b/.env.example index f7f2a2c..ecddaa5 100644 --- a/.env.example +++ b/.env.example @@ -1,11 +1,3 @@ -# API Configuration -NEXT_PUBLIC_API_URL=http://localhost:3000 -NEXT_PUBLIC_KOMGA_URL=http://localhost:8080 - -# Authentication -NEXTAUTH_URL=http://localhost:3000 -NEXTAUTH_SECRET=your-secret-key-here - # Database MONGODB_URI=mongodb://localhost:27017/stripstream @@ -13,6 +5,3 @@ MONGODB_URI=mongodb://localhost:27017/stripstream MONGO_USER=admin MONGO_PASSWORD=password MONGODB_URI=mongodb://admin:password@localhost:27017/stripstream?authSource=admin - -# Komga -NEXT_PUBLIC_API_URL=https://cloud.julienfroidefond.com \ No newline at end of file diff --git a/README.md b/README.md index 9bca524..a1ef8c4 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,6 @@ npm install 3. Créer un fichier `.env.local` à la racine du projet -```bash -NEXT_PUBLIC_API_URL=https://cloud.julienfroidefond.com -``` - 4. Lancer le serveur de développement ```bash diff --git a/docker-compose.yml b/docker-compose.yml index 616d034..b124583 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,6 @@ services: - /app/.next environment: - NODE_ENV=development - - NEXT_PUBLIC_API_URL= ${NEXT_PUBLIC_API_URL} command: npm run dev mongodb: diff --git a/src/components/layout/SidebarWrapper.tsx b/src/components/layout/SidebarWrapper.tsx index 7f4cecb..6ac09a2 100644 --- a/src/components/layout/SidebarWrapper.tsx +++ b/src/components/layout/SidebarWrapper.tsx @@ -1,25 +1,16 @@ import { FavoriteService } from "@/lib/services/favorite.service"; import { LibraryService } from "@/lib/services/library.service"; +import { SeriesService } from "@/lib/services/series.service"; export async function SidebarWrapper() { // Récupérer les favoris depuis le serveur const favoriteIds = await FavoriteService.getAllFavoriteIds(); // Récupérer les détails des séries favorites - const favoritesPromises = favoriteIds.map(async (id) => { - const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/series/${id}`, { - headers: { - Accept: "application/json", - }, - }); - if (!response.ok) return null; - return response.json(); - }); + const favorites = await SeriesService.getMultipleSeries(favoriteIds); // Récupérer les bibliothèques const libraries = await LibraryService.getLibraries(); - const favorites = (await Promise.all(favoritesPromises)).filter(Boolean); - return { favorites, libraries }; } diff --git a/src/lib/services/series.service.ts b/src/lib/services/series.service.ts index 138b47f..a491cfc 100644 --- a/src/lib/services/series.service.ts +++ b/src/lib/services/series.service.ts @@ -105,4 +105,14 @@ export class SeriesService extends BaseApiService { static getCoverUrl(seriesId: string): string { return `/api/komga/images/series/${seriesId}/thumbnail`; } + + static async getMultipleSeries(seriesIds: string[]): Promise { + try { + const seriesPromises = seriesIds.map((id) => this.getSeries(id)); + const series = await Promise.all(seriesPromises); + return series.filter(Boolean); + } catch (error) { + return this.handleError(error, "Impossible de récupérer les séries"); + } + } }