Эх сурвалжийг харах

RHL-001-refactor: update parameter handling in GET requests for branches, months, and years endpoints

Code_Uwe 1 долоо хоног өмнө
parent
commit
79d43a50cb

+ 7 - 4
app/api/branches/[branch]/[year]/[month]/days/route.js

@@ -1,10 +1,13 @@
 import { NextResponse } from "next/server";
 import { listDays } from "@/lib/storage";
 
-export async function GET(request, { params }) {
-	console.log("[/api/branches/[branch]/[year]/[month]/days] params:", params);
-
-	const { branch, year, month } = params || {};
+export async function GET(request, ctx) {
+	const { branch, year, month } = await ctx.params;
+	console.log("[/api/branches/[branch]/[year]/[month]/days] params:", {
+		branch,
+		year,
+		month,
+	});
 
 	if (!branch || !year || !month) {
 		return NextResponse.json(

+ 6 - 4
app/api/branches/[branch]/[year]/months/route.js

@@ -1,10 +1,12 @@
 import { NextResponse } from "next/server";
 import { listMonths } from "@/lib/storage";
 
-export async function GET(request, { params }) {
-	console.log("[/api/branches/[branch]/[year]/months] params:", params);
-
-	const { branch, year } = params || {};
+export async function GET(request, ctx) {
+	const { branch, year } = await ctx.params;
+	console.log("[/api/branches/[branch]/[year]/months] params:", {
+		branch,
+		year,
+	});
 
 	if (!branch || !year) {
 		return NextResponse.json(

+ 3 - 4
app/api/branches/[branch]/years/route.js

@@ -1,10 +1,9 @@
 import { NextResponse } from "next/server";
 import { listYears } from "@/lib/storage";
 
-export async function GET(request, { params }) {
-	console.log("[/api/branches/[branch]/years] params:", params);
-
-	const { branch } = params || {};
+export async function GET(request, ctx) {
+	const { branch } = await ctx.params;
+	console.log("[/api/branches/[branch]/years] params:", { branch });
 
 	if (!branch) {
 		return NextResponse.json(