mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Intitial commit
This commit is contained in:
33
lib/sanity/sanity.api.ts
Normal file
33
lib/sanity/sanity.api.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* As this file is reused in several other files, try to keep it lean and small.
|
||||
* Importing other npm packages here could lead to needlessly increasing the client bundle size, or end up in a server-only function that don't need it.
|
||||
*/
|
||||
|
||||
export const dataset = assertValue(
|
||||
process.env.NEXT_PUBLIC_SANITY_DATASET,
|
||||
'Missing environment variable: NEXT_PUBLIC_SANITY_DATASET',
|
||||
)
|
||||
|
||||
export const projectId = assertValue(
|
||||
process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
|
||||
'Missing environment variable: NEXT_PUBLIC_SANITY_PROJECT_ID',
|
||||
)
|
||||
|
||||
// see https://www.sanity.io/docs/api-versioning for how versioning works
|
||||
export const apiVersion =
|
||||
process.env.NEXT_PUBLIC_SANITY_API_VERSION || '2023-06-21'
|
||||
|
||||
// This is the document id used for the preview secret that's stored in your dataset.
|
||||
// The secret protects against unauthorized access to your draft content and have a lifetime of 60 minutes, to protect against bruteforcing.
|
||||
export const previewSecretId: `${string}.${string}` = 'preview.secret'
|
||||
|
||||
// See the app/api/revalidate/route.ts for how this is used
|
||||
export const revalidateSecret = process.env.SANITY_REVALIDATE_SECRET
|
||||
|
||||
function assertValue<T>(v: T | undefined, errorMessage: string): T {
|
||||
if (v === undefined) {
|
||||
throw new Error(errorMessage)
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
Reference in New Issue
Block a user