Skip to content

Commit 8c0026a

Browse files
feat: implement GET endpoint for weather widget feature flag
1 parent 9f3ad08 commit 8c0026a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/app/api/flags/route.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import "@vercel/flags/next";
2+
3+
export async function GET() {
4+
const isEnabled = unstable_flag("WeatherWidgetEnabled", false);
5+
return new Response(JSON.stringify({ isEnabled }), {
6+
headers: { "Content-Type": "application/json" },
7+
});
8+
}
9+
function unstable_flag(flagName: string, defaultValue: boolean): boolean {
10+
// Simulate a feature flag check. In a real-world scenario, this might query a database or an external service.
11+
const featureFlags: Record<string, boolean> = {
12+
WeatherWidgetEnabled: true, // Example flag
13+
};
14+
15+
return featureFlags[flagName] ?? defaultValue;
16+
}

0 commit comments

Comments
 (0)