Files
Dominik Ferber db89f0dfb1 Init
2024-12-12 13:01:06 +02:00

51 lines
1.1 KiB
TypeScript

import { flag } from '@vercel/flags/next';
export const hasAuthCookieFlag = flag({
key: 'hasAuthCookie',
// defaultValue: false,
// options: [false, true],
// description: 'checks auth',
// origin: 'https://example.com/#hasAuthCookie',
async decide({ cookies }) {
return cookies.get('fake-auth-cookie')?.value === '1';
},
});
export const showRatingFlag = flag({
key: 'showRating',
// defaultValue: false,
// options: [false, true],
async decide() {
return false;
},
});
export const footerFlag = flag<{
url: string;
text: string;
}>({
key: 'jsonFlag',
options: [
{
label: 'Website',
value: { url: 'https://vercel.com/', text: 'vercel.com' },
},
{
label: 'Twitter',
value: { url: 'https://twitter.com/vercel', text: '@vercel' },
},
],
async decide() {
return { url: 'https://vercel.com/', text: 'vercel.com' };
// alternatively we could return from the options list directly
// return this.options[0].value;
},
});
export const precomputeFlags = [
hasAuthCookieFlag,
showRatingFlag,
footerFlag,
] as const;