fix: slug in routes
This commit is contained in:
@@ -7,11 +7,12 @@ import { AppError } from "@/utils/errors";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ bookId: string; pageNumber: string }> }
|
||||
) {
|
||||
try {
|
||||
const params = request.nextUrl.searchParams;
|
||||
const pageNumberParam = params.get("pageNumber") || "0";
|
||||
const bookIdParam = params.get("bookId") || "";
|
||||
const { bookId: bookIdParam, pageNumber: pageNumberParam } = await params;
|
||||
|
||||
const pageNumber: number = parseInt(pageNumberParam);
|
||||
if (isNaN(pageNumber) || pageNumber < 0) {
|
||||
|
||||
@@ -5,11 +5,13 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { AppError } from "@/utils/errors";
|
||||
|
||||
export async function PATCH(request: NextRequest) {
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ bookId: string }> }
|
||||
) {
|
||||
try {
|
||||
const { page, completed } = await request.json();
|
||||
const params = request.nextUrl.searchParams;
|
||||
const bookId: string = params.get("bookId") || "";
|
||||
const bookId: string = (await params).bookId;
|
||||
|
||||
if (typeof page !== "number") {
|
||||
return NextResponse.json(
|
||||
@@ -53,10 +55,12 @@ export async function PATCH(request: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(request: NextRequest) {
|
||||
export async function DELETE(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ bookId: string }> }
|
||||
) {
|
||||
try {
|
||||
const params = request.nextUrl.searchParams;
|
||||
const bookId: string = params.get("bookId") || "";
|
||||
const bookId: string = (await params).bookId;
|
||||
|
||||
await BookService.deleteReadProgress(bookId);
|
||||
return NextResponse.json({ message: "🗑️ Progression supprimée avec succès" });
|
||||
|
||||
@@ -6,10 +6,12 @@ import { AppError } from "@/utils/errors";
|
||||
import type { KomgaBookWithPages } from "@/types/komga";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ bookId: string }> }
|
||||
) {
|
||||
try {
|
||||
const params = request.nextUrl.searchParams;
|
||||
const bookId: string = params.get("bookId") || "";
|
||||
const bookId: string = (await params).bookId;
|
||||
|
||||
const data: KomgaBookWithPages = await BookService.getBook(bookId);
|
||||
return NextResponse.json(data);
|
||||
|
||||
@@ -7,11 +7,12 @@ import { SeriesService } from "@/lib/services/series.service";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
export async function POST(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ libraryId: string; seriesId: string }> }
|
||||
) {
|
||||
try {
|
||||
const params = request.nextUrl.searchParams;
|
||||
const libraryId: string = params.get("libraryId") || "";
|
||||
const seriesId: string = params.get("seriesId") || "";
|
||||
const { libraryId, seriesId } = await params;
|
||||
|
||||
await HomeService.invalidateHomeCache();
|
||||
revalidatePath("/");
|
||||
|
||||
@@ -7,11 +7,12 @@ import { getErrorMessage } from "@/utils/errors";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ bookId: string; pageNumber: string }> }
|
||||
) {
|
||||
try {
|
||||
const params = request.nextUrl.searchParams;
|
||||
const bookId: string = params.get("bookId") || "";
|
||||
const pageNumber: string = params.get("pageNumber") || "";
|
||||
const { bookId, pageNumber } = await params;
|
||||
|
||||
const response = await BookService.getPage(bookId, parseInt(pageNumber));
|
||||
return response;
|
||||
|
||||
@@ -7,11 +7,12 @@ import { getErrorMessage } from "@/utils/errors";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ bookId: string; pageNumber: string }> }
|
||||
) {
|
||||
try {
|
||||
const params = request.nextUrl.searchParams;
|
||||
const bookId: string = params.get("bookId") || "";
|
||||
const pageNumberParam: string = params.get("pageNumber") || "";
|
||||
const { bookId, pageNumber: pageNumberParam } = await params;
|
||||
|
||||
const pageNumber: number = parseInt(pageNumberParam);
|
||||
if (isNaN(pageNumber) || pageNumber < 0) {
|
||||
|
||||
@@ -5,10 +5,12 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ bookId: string }> }
|
||||
) {
|
||||
try {
|
||||
const params = request.nextUrl.searchParams;
|
||||
const bookId: string = params.get("bookId") || "";
|
||||
const bookId: string = (await params).bookId;
|
||||
|
||||
const response = await BookService.getCover(bookId);
|
||||
return response;
|
||||
|
||||
@@ -7,10 +7,12 @@ import { getErrorMessage } from "@/utils/errors";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ seriesId: string }> }
|
||||
) {
|
||||
try {
|
||||
const params = request.nextUrl.searchParams;
|
||||
const seriesId: string = params.get("seriesId") || "";
|
||||
const seriesId: string = (await params).seriesId;
|
||||
|
||||
const response = await SeriesService.getCover(seriesId);
|
||||
return response;
|
||||
|
||||
@@ -5,11 +5,12 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { AppError } from "@/utils/errors";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ seriesId: string }> }
|
||||
) {
|
||||
try {
|
||||
const params = request.nextUrl.searchParams;
|
||||
const seriesId: string = params.get("seriesId") || "";
|
||||
|
||||
const seriesId: string = (await params).seriesId;
|
||||
const response = await SeriesService.getCover(seriesId);
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
||||
@@ -7,10 +7,12 @@ import { getErrorMessage } from "@/utils/errors";
|
||||
import type { NextRequest } from "next/server";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ seriesId: string }> }
|
||||
) {
|
||||
try {
|
||||
const params = request.nextUrl.searchParams;
|
||||
const seriesId: string = params.get("seriesId") || "";
|
||||
const seriesId: string = (await params).seriesId;
|
||||
|
||||
const series: KomgaSeries = await SeriesService.getSeries(seriesId);
|
||||
return NextResponse.json(series);
|
||||
|
||||
Reference in New Issue
Block a user