feat: update items

This commit is contained in:
David Nguyen
2023-08-21 12:16:06 +10:00
parent d0720f4c70
commit ba95818da4
3 changed files with 5 additions and 5 deletions

View File

@ -2,7 +2,7 @@ import { z } from 'zod';
import { LOCAL_FEATURE_FLAGS, isFeatureFlagEnabled } from '@documenso/lib/constants/feature-flags'; import { LOCAL_FEATURE_FLAGS, isFeatureFlagEnabled } from '@documenso/lib/constants/feature-flags';
import { TFeatureFlagValue } from '~/providers/feature-flag'; import { TFeatureFlagValue, ZFeatureFlagValueSchema } from '~/providers/feature-flag';
/** /**
* Evaluate whether a flag is enabled for the current user. * Evaluate whether a flag is enabled for the current user.
@ -33,7 +33,7 @@ export const getFlag = async (
}, },
}) })
.then((res) => res.json()) .then((res) => res.json())
.then((res) => z.union([z.boolean(), z.string()]).parse(res)) .then((res) => ZFeatureFlagValueSchema.parse(res))
.catch(() => false); .catch(() => false);
return response; return response;
@ -65,7 +65,7 @@ export const getAllFlags = async (
}, },
}) })
.then((res) => res.json()) .then((res) => res.json())
.then((res) => z.record(z.string(), z.union([z.boolean(), z.string()])).parse(res)) .then((res) => z.record(z.string(), ZFeatureFlagValueSchema).parse(res))
.catch(() => LOCAL_FEATURE_FLAGS); .catch(() => LOCAL_FEATURE_FLAGS);
}; };

View File

@ -38,7 +38,7 @@ export default async function handler(req: Request) {
const res = NextResponse.json(featureFlags); const res = NextResponse.json(featureFlags);
res.headers.set('Cache-Control', 'public, s-maxage=120, stale-while-revalidate=60'); res.headers.set('Cache-Control', 'public, s-maxage=60, stale-while-revalidate=300');
return res; return res;
} }

View File

@ -57,7 +57,7 @@ export default async function handler(req: Request) {
const res = NextResponse.json(featureFlag); const res = NextResponse.json(featureFlag);
res.headers.set('Cache-Control', 'public, s-maxage=120, stale-while-revalidate=60'); res.headers.set('Cache-Control', 'public, s-maxage=60, stale-while-revalidate=300');
return res; return res;
} }