Skip to content

Commit

Permalink
feat: env logger
Browse files Browse the repository at this point in the history
  • Loading branch information
denchiklut committed Sep 29, 2024
1 parent 497e177 commit c9bbe6a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/common/env/env.util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { TypeOf, ZodObject, ZodRawShape } from 'zod'
import { logger } from '../logger'

interface Props<T extends ZodRawShape> {
schema: ZodObject<T>
Expand All @@ -21,10 +22,10 @@ export function createEnv<S extends ZodRawShape>({
}, {})
)

const { success, data, error } = (IS_SERVER || IS_SPA ? schema : client).safeParse(envs)
const { success, data, error } = (IS_SERVER ? schema : client).safeParse(envs)

if (!success) {
console.error('❌ Invalid environment variables:', error.flatten().fieldErrors)
logger.error('❌ Invalid environment variables:', error.flatten().fieldErrors)
throw new Error('Invalid environment variables')
}

Expand Down

0 comments on commit c9bbe6a

Please sign in to comment.