Skip to content

Commit bf4bced

Browse files
feat: update GET endpoint to use NextResponse for JSON response
1 parent 8c0026a commit bf4bced

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/app/api/flags/route.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
import "@vercel/flags/next";
1+
import { NextResponse } from "next/server";
22

33
export async function GET() {
44
const isEnabled = unstable_flag("WeatherWidgetEnabled", false);
5-
return new Response(JSON.stringify({ isEnabled }), {
6-
headers: { "Content-Type": "application/json" },
7-
});
5+
return NextResponse.json({ isEnabled });
86
}
7+
98
function unstable_flag(flagName: string, defaultValue: boolean): boolean {
109
// Simulate a feature flag check. In a real-world scenario, this might query a database or an external service.
1110
const featureFlags: Record<string, boolean> = {
1211
WeatherWidgetEnabled: true, // Example flag
1312
};
1413

14+
if (!(flagName in featureFlags)) {
15+
console.warn(`Feature flag "${flagName}" not found. Using default value.`);
16+
}
17+
1518
return featureFlags[flagName] ?? defaultValue;
1619
}

0 commit comments

Comments
 (0)