Skip to content

feat: type-safe env via @t3-oss/env-core + zod - #139

Merged
HugoPerard merged 9 commits into
BearStudio:mainfrom
azizbecha:feat/typesafe-env
Jun 16, 2026
Merged

feat: type-safe env via @t3-oss/env-core + zod#139
HugoPerard merged 9 commits into
BearStudio:mainfrom
azizbecha:feat/typesafe-env

Conversation

@azizbecha

Copy link
Copy Markdown
Contributor

Replaced ad-hoc process.env access with a validated env module so missing or malformed vars fail fast at startup instead of producing undefined runtime values, in addition to having typed env vars instead of ghosted process.env.*.

@azizbecha

Copy link
Copy Markdown
Contributor Author

cc @yoannfleurydev

@yoannfleurydev yoannfleurydev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contributions. I think we will be good to go after the suggested changes.

Comment thread package.json Outdated
@azizbecha

Copy link
Copy Markdown
Contributor Author

Done, thanks for the review!
Let me know if there are any other changes required, alongside with the other PRs opened.

@yoannfleurydev

Copy link
Copy Markdown
Member

We'll need to skip the validations for the CI I guess

image

@azizbecha

Copy link
Copy Markdown
Contributor Author

Yes! The env schema rename to EXPO_PUBLIC_BASE_URL requires updating the workflow files too, since they still export the old EXPO_PUBLIC_API_URL name. I'll push a fix renaming it across all 6 workflows, and add SKIP_ENV_VALIDATION=true to the lint/typecheck jobs so they don't need the repo variables set at all.

Separately, I think the workflows could be reorganized so each does one thing, happy to open a follow-up issue for that.

Comment thread src/env.ts Outdated
@azizbecha

Copy link
Copy Markdown
Contributor Author

Nice catch! Fixed that in a new commit. The new code looks cleaner now.

Comment thread src/env.ts Outdated
azizbecha and others added 6 commits June 16, 2026 09:00
Replace ad-hoc process.env access with a validated env module so missing
or malformed vars fail fast at startup instead of producing undefined
runtime values.
The env schema rename in 12d0497 wasn't propagated to the GitHub Actions
workflows, causing every job to fail at `pnpm install` because the
`prepare` hook runs `gen:api`, which loads `src/env.ts` and rejects an
undefined `EXPO_PUBLIC_BASE_URL`.

Also adds a public demo URL fallback in code-quality.yml so lint and
typecheck pass on forks where `vars.API_URL` isn't configured.
Derive EXPO_PUBLIC_AUTH_URL and EXPO_PUBLIC_OPENAPI_URL from
EXPO_PUBLIC_BASE_URL inside `runtimeEnv` so both vars are always
defined and validated as URLs. Consumers now read `env.EXPO_PUBLIC_*`
directly without per-call-site fallback logic.
# Conflicts:
#	src/components/ui/badge.tsx
#	src/components/ui/button.tsx
#	src/components/ui/pin-input.tsx
#	src/features/auth/view-otp-verification.tsx
@HugoPerard
HugoPerard merged commit 1361015 into BearStudio:main Jun 16, 2026
2 of 3 checks passed
@HugoPerard

Copy link
Copy Markdown
Member

Thanks a lot @azizbecha for the contribution! ❤️

I only made a couple of small adjustments:

  • Made some environment variables optional.
  • Added Hey API contract versioning, which was already under discussion on our side and also fixes a CI issue we were facing.

Everything else looks great. Thanks again for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants