mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
feat: update items
This commit is contained in:
@ -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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user