fix: slug in routes

This commit is contained in:
Julien Froidefond
2025-03-02 15:06:04 +01:00
parent e60b48d549
commit 3e1f446e8b
10 changed files with 55 additions and 38 deletions

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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;

View File

@@ -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) {