fix: types of nj15
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { NextRequest} from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { NextResponse } from "next/server";
|
||||
import { BookService } from "@/lib/services/book.service";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
@@ -7,12 +7,13 @@ import { AppError } from "@/utils/errors";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { bookId: string; pageNumber: string } }
|
||||
) {
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const pageNumber: number = parseInt(params.pageNumber);
|
||||
const params = request.nextUrl.searchParams;
|
||||
const pageNumberParam = params.get("pageNumber") || "0";
|
||||
const bookIdParam = params.get("bookId") || "";
|
||||
|
||||
const pageNumber: number = parseInt(pageNumberParam);
|
||||
if (isNaN(pageNumber) || pageNumber < 0) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
@@ -26,7 +27,7 @@ export async function GET(
|
||||
);
|
||||
}
|
||||
|
||||
const response = await BookService.getPage(params.bookId, pageNumber);
|
||||
const response = await BookService.getPage(bookIdParam, pageNumber);
|
||||
const buffer = await response.arrayBuffer();
|
||||
const headers = new Headers();
|
||||
headers.set("Content-Type", response.headers.get("Content-Type") || "image/jpeg");
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import type { NextRequest} from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { NextResponse } from "next/server";
|
||||
import { BookService } from "@/lib/services/book.service";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { AppError } from "@/utils/errors";
|
||||
|
||||
export async function PATCH(request: NextRequest, { params }: { params: { bookId: string } }) {
|
||||
export async function PATCH(request: NextRequest) {
|
||||
try {
|
||||
const { page, completed } = await request.json();
|
||||
const params = request.nextUrl.searchParams;
|
||||
const bookId: string = params.get("bookId") || "";
|
||||
|
||||
if (typeof page !== "number") {
|
||||
return NextResponse.json(
|
||||
@@ -22,7 +24,7 @@ export async function PATCH(request: NextRequest, { params }: { params: { bookId
|
||||
);
|
||||
}
|
||||
|
||||
await BookService.updateReadProgress(params.bookId, page, completed);
|
||||
await BookService.updateReadProgress(bookId, page, completed);
|
||||
return NextResponse.json({ message: "📖 Progression mise à jour avec succès" });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la mise à jour de la progression:", error);
|
||||
@@ -51,9 +53,12 @@ export async function PATCH(request: NextRequest, { params }: { params: { bookId
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(request: NextRequest, { params }: { params: { bookId: string } }) {
|
||||
export async function DELETE(request: NextRequest) {
|
||||
try {
|
||||
await BookService.deleteReadProgress(params.bookId);
|
||||
const params = request.nextUrl.searchParams;
|
||||
const bookId: string = params.get("bookId") || "";
|
||||
|
||||
await BookService.deleteReadProgress(bookId);
|
||||
return NextResponse.json({ message: "🗑️ Progression supprimée avec succès" });
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la suppression de la progression:", error);
|
||||
|
||||
@@ -4,9 +4,14 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import type { KomgaBookWithPages } from "@/types/komga";
|
||||
export async function GET(request: Request, { params }: { params: { bookId: string } }) {
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const data: KomgaBookWithPages = await BookService.getBook(params.bookId);
|
||||
const params = request.nextUrl.searchParams;
|
||||
const bookId: string = params.get("bookId") || "";
|
||||
|
||||
const data: KomgaBookWithPages = await BookService.getBook(bookId);
|
||||
return NextResponse.json(data);
|
||||
} catch (error) {
|
||||
console.error("API Books - Erreur:", error);
|
||||
|
||||
Reference in New Issue
Block a user