Skip to content

Commit b155186

Browse files
committed
refactor(api): define explicit type for context parameter in GET handler for schema retrieval
1 parent 1af321e commit b155186

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/api/get-schema/[name]/route.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import { NextResponse, NextRequest } from "next/server";
22
import fs from "fs/promises";
33
import path from "path";
44

5+
// Explicitly define the type for the context parameter
6+
interface RouteContext {
7+
params: {
8+
name: string;
9+
};
10+
}
11+
512
// Helper function to safely join paths and prevent traversal
613
function safeJoin(base: string, target: string): string | null {
714
const targetPath = "." + path.normalize("/" + target);
@@ -16,9 +23,9 @@ function safeJoin(base: string, target: string): string | null {
1623

1724
export async function GET(
1825
request: NextRequest,
19-
{ params }: { params: { name: string } }
26+
context: RouteContext // Use the explicitly defined type
2027
) {
21-
const schemaName = params.name;
28+
const schemaName = context.params.name;
2229

2330
if (!schemaName) {
2431
return NextResponse.json({ error: "Schema name required" }, { status: 400 });

0 commit comments

Comments
 (0)