Skip to content

Commit

Permalink
fix: json parse for env VITE_FIREBASE_CONFIG
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Oct 12, 2024
1 parent 8809475 commit b2916bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
4 changes: 2 additions & 2 deletions apps/main/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const registerPushNotifications = async () => {

const instance = new PushReceiver({
debug: true,
firebase: env.VITE_FIREBASE_CONFIG,
firebase: JSON.parse(env.VITE_FIREBASE_CONFIG),
persistentIds: persistentIds || [],
credentials: credentials || null,
bundleId: "is.follow",
Expand Down Expand Up @@ -201,7 +201,7 @@ const registerPushNotifications = async () => {
try {
await instance.connect()
} catch (error) {
logger.error(`PushReceiver error: ${error}`)
logger.error(`PushReceiver error: ${error instanceof Error ? error.stack : error}`)
}

logger.info("PushReceiver connected")
Expand Down
22 changes: 1 addition & 21 deletions packages/shared/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,7 @@ export const env = createEnv({
VITE_SENTRY_DSN: z.string().optional(),
VITE_POSTHOG_KEY: z.string().optional(),
VITE_INBOXES_EMAIL: z.string().default("@follow.re"),
VITE_FIREBASE_CONFIG: z
.string()
.transform((content) => {
try {
return JSON.parse(content)
} catch {
return z.NEVER
}
})
.pipe(
z.object({
apiKey: z.string(),
authDomain: z.string(),
projectId: z.string(),
storageBucket: z.string(),
messagingSenderId: z.string(),
appId: z.string(),
measurementId: z.string(),
}),
)
.optional(),
VITE_FIREBASE_CONFIG: z.string().optional(),
},

emptyStringAsUndefined: true,
Expand Down

0 comments on commit b2916bd

Please sign in to comment.