feat: route config pour les front
This commit is contained in:
parent
41dc3c51aa
commit
ed0a075a6c
@@ -1,7 +1,7 @@
|
||||
---
|
||||
description:
|
||||
globs:
|
||||
alwaysApply: true
|
||||
alwaysApply: false
|
||||
---
|
||||
```
|
||||
Domain/Manga/Infrastructure/ApiPlatform/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
description: need to create or find a job
|
||||
description:
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
description:
|
||||
globs:
|
||||
alwaysApply: true
|
||||
alwaysApply: false
|
||||
---
|
||||
# Tests de Mangarr
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -37,11 +37,25 @@ export class ApiMangaRepository {
|
||||
|
||||
async getChapters(mangaId) {
|
||||
try {
|
||||
const response = await fetch(`/api/mangas/${mangaId}/chapters`);
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch manga 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');
|
||||
}
|
||||
const data = await response.json();
|
||||
allChapters = allChapters.concat(data.items);
|
||||
hasMore = data.hasNextPage;
|
||||
page++;
|
||||
}
|
||||
return await response.json();
|
||||
|
||||
return {
|
||||
items: allChapters,
|
||||
total: allChapters.length
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('API Error:', error);
|
||||
throw error;
|
||||
|
||||
@@ -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: ".*"
|
||||
|
||||
Reference in New Issue
Block a user