forked from vercel/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Vercel Toolbar and Flags integration to Hypertune example (vercel…
…#871) Add Vercel Toolbar and Flags integration to Hypertune example
- Loading branch information
Showing
19 changed files
with
505 additions
and
271 deletions.
There are no files selected for viewing
Submodule feature-flag-hypertune-101
added at
7882e6
Submodule feature-flag-hypertune-65
added at
9c4065
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
edge-middleware/feature-flag-hypertune/app/.well-known/vercel/flags/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { NextResponse } from 'next/server' | ||
import { encryptApiData } from '@vercel/flags' | ||
import { vercelFlagDefinitions } from '../../../../generated/generated' | ||
|
||
export async function GET() { | ||
const apiData = { definitions: vercelFlagDefinitions } | ||
const encryptedApiData = await encryptApiData(apiData) | ||
return NextResponse.json(encryptedApiData) | ||
} |
9 changes: 2 additions & 7 deletions
9
edge-middleware/feature-flag-hypertune/app/api/flags/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
import { NextResponse } from 'next/server' | ||
import hypertune from '../../../lib/hypertune' | ||
import getHypertune from '../../../lib/getHypertune' | ||
|
||
export const runtime = 'edge' | ||
export const dynamic = 'force-dynamic' | ||
|
||
export async function GET() { | ||
await hypertune.initFromServerIfNeeded() | ||
const rootNode = await getHypertune() | ||
|
||
const rootNode = hypertune.root({ | ||
context: { | ||
user: { id: 'test', name: 'Test', email: '[email protected]' }, | ||
}, | ||
}) | ||
const exampleFlag = rootNode.exampleFlag().get(/* fallback */ false) | ||
console.log('Edge Function flag:', exampleFlag) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.