Skip to content

Commit

Permalink
Merge pull request #30 from thomasKn/fix
Browse files Browse the repository at this point in the history
Fix type
  • Loading branch information
thomasKn authored Feb 3, 2024
2 parents c89050b + 7a278c4 commit fa079ff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
4 changes: 1 addition & 3 deletions app/lib/env.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
*/

export function envVariables(contextEnv: Env) {
let env: Env | NodeJS.ProcessEnv;
let env: Env | NodeJS.ProcessEnv = contextEnv;

if (typeof process !== 'undefined') {
// Process is accessible in Vercel environment
env = process.env;
} else {
env = contextEnv;
}

return {
Expand Down
23 changes: 17 additions & 6 deletions app/lib/sanity/sanity.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import {loadQuery, queryStore} from './sanity.loader';
type CreateSanityClientOptions = {
cache: Cache;
config: {
apiVersion: string;
dataset: string;
projectId: string;
studioUrl: string;
useCdn: boolean;
useStega: string;
apiVersion: string | undefined;
dataset: string | undefined;
projectId: string | undefined;
studioUrl: string | undefined;
useCdn: boolean | undefined;
useStega: string | undefined;
};
waitUntil: ExecutionContext['waitUntil'];
};
Expand Down Expand Up @@ -52,6 +52,17 @@ export function createSanityClient(options: CreateSanityClientOptions) {
const {cache, config, waitUntil} = options;
const {apiVersion, dataset, projectId, studioUrl, useCdn, useStega} = config;

if (
typeof projectId === 'undefined' ||
typeof apiVersion === 'undefined' ||
typeof dataset === 'undefined' ||
typeof studioUrl === 'undefined' ||
typeof useCdn === 'undefined' ||
typeof useStega === 'undefined'
) {
throw new Error('Missing required configuration for Sanity client');
}

const {client} = getSanityClient({
apiVersion,
dataset,
Expand Down

0 comments on commit fa079ff

Please sign in to comment.