feat: route config pour les front

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-03-24 18:21:07 +01:00
parent 41dc3c51aa
commit ed0a075a6c
6 changed files with 29 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
---
description:
globs:
alwaysApply: true
alwaysApply: false
---
```
Domain/Manga/Infrastructure/ApiPlatform/

View File

@@ -1,5 +1,5 @@
---
description: need to create or find a job
description:
globs:
alwaysApply: false
---

View File

@@ -1,7 +1,7 @@
---
description:
globs:
alwaysApply: true
alwaysApply: false
---
# Tests de Mangarr

View File

@@ -1,17 +0,0 @@
export class MangaApi {
static async fetchById(mangaId) {
const response = await fetch(`/api/mangas/${mangaId}`);
if (!response.ok) {
throw new Error('Failed to fetch manga details');
}
return response.json();
}
static async fetchChapters(mangaId) {
const response = await fetch(`/api/mangas/${mangaId}/chapters`);
if (!response.ok) {
throw new Error('Failed to fetch manga chapters');
}
return response.json();
}
}

View File

@@ -37,11 +37,25 @@ export class ApiMangaRepository {
async getChapters(mangaId) {
try {
const response = await fetch(`/api/mangas/${mangaId}/chapters`);
let allChapters = [];
let page = 1;
let hasMore = true;
while (hasMore) {
const response = await fetch(`/api/mangas/${mangaId}/chapters?limit=500&page=${page}`);
if (!response.ok) {
throw new Error('Failed to fetch manga chapters');
}
return await response.json();
const data = await response.json();
allChapters = allChapters.concat(data.items);
hasMore = data.hasNextPage;
page++;
}
return {
items: allChapters,
total: allChapters.length
};
} catch (error) {
console.error('API Error:', error);
throw error;

View File

@@ -5,13 +5,19 @@ controllers:
type: attribute
react_app:
path: /react
path: /react/{req}
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
defaults:
template: 'react/index.html.twig'
req: ''
requirements:
req: ".*"
vue_app:
path: /vue
path: /vue/{req}
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
defaults:
template: 'vue/index.html.twig'
req: ''
requirements:
req: ".*"