feat: debut d'un front vue.js + ajout de cursorrules
This commit is contained in:
parent
ca9a74fe69
commit
bee8572dc5
@@ -0,0 +1,50 @@
|
||||
import { MangaCollection } from '../../domain/entities/manga';
|
||||
|
||||
export class ApiMangaRepository {
|
||||
async getCollection() {
|
||||
try {
|
||||
const response = await fetch('/api/mangas');
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch manga collection');
|
||||
}
|
||||
const data = await response.json();
|
||||
return new MangaCollection(
|
||||
data.items,
|
||||
data.total,
|
||||
data.page,
|
||||
data.limit,
|
||||
data.hasNextPage,
|
||||
data.hasPreviousPage
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('API Error:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async getMangaBySlug(slug) {
|
||||
try {
|
||||
const response = await fetch(`/api/mangas/${slug}`);
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch manga details');
|
||||
}
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('API Error:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async searchMangas(query) {
|
||||
try {
|
||||
const response = await fetch(`/api/mangas/search?q=${encodeURIComponent(query)}`);
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to search mangas');
|
||||
}
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('API Error:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user