Home

madison / open-git

public
Code Branches Pull requestsIssuesInsights Campfire Docs
main
Home Code PRsIssues

[feat] Convert to typesafe env vars

open
#61 opened by madisonfeat/t3-env→main
Conversation4 Commits2
Files changed
34
madisonopened this pull requestAuthor· 3 weeks ago

This PR does two things:

  1. First public testing of entire.io integration
  2. Converts entire codebase to be typesafe using t3/env
  1. Please implement https://env.t3.gg/docs/introduction into our codebase.

    170 calls

    I'll look up T3 Env's setup docs and how this repo currently handles env vars so we can wire it in cleanly.

    Next I'll inventory the env vars in use and how the Next.js apps are structured so the T3 schema matches reality.

    I'll dig into how optional vs required env vars are treated, plus Docker/build setup so validation doesn't break CI.

    Installing the package and adding validated env schemas for the Next.js apps, then migrating call sites.

    Migrating call sites to use the validated env object.

    Env schema validates against local .env. Running typechecks next.

    Next's config loader is choking on the .ts config; I'll switch to the documented jiti approach with next.config.mjs.

    env.tssite.tsnext.config.mjs+26 more

    T3 Env is wired into the Next.js apps.

    What changed

    • Added [@t3-oss](/t3-oss)/env-nextjs (+ jiti for config-time validation) to web and community
    • Created validated schemas:
      • apps/web/env.ts — server/client split for all app env vars
      • apps/community/env.ts — NEXT_PUBLIC_MAIN_APP_URL
    • Imported schemas from next.config.mjs so env fails at dev/build time (Next.js guide)
    • Migrated app/lib/db call sites from process.env → env
    • Left process.env.NODE_ENV in client/shared UI code (Next inlines it; env.NODE_ENV would throw on the client)
    • Seed/worker scripts still use process.env after loadEnvFile (they load env before dynamic imports)

    Usage

    import { env } from "@/env"
    
    env.DATABASE_URL // typed, validated
    env.WAITLIST_ENABLED // boolean via z.stringbool()
    

    Required vars (fail fast): DATABASE_URL, APP_URL, BETTER_AUTH_SECRET, code-storage credentials, GIT_REMOTE_BASE_URL. Optional ones use emptyStringAsUndefined so blank .env entries are fine.

    228f0acinit t3 env conversion+399 -181
    93% agent-written350 agent linesd1b1e8a0106e
Open Git PR AutopilotBotpushed 1 commit· 3 weeks ago
Open Git PR AutopilotBotran on this pull request· 3 weeks ago

The focused CI fix is already present in commit 6d5a4ca. It makes nonessential URL variables optional for test-time environment validation, supplies the existing localhost clone URL fallback at its use site, configures the Vitest @ alias, and isolates the admin unit test from the full environment schema. The provided verification run completed successfully: 5 test tasks passed, including all 116 web tests, with no working-tree changes remaining.

No file changes were produced.

Triggered by check.failed

Automated run · @autopilot
Open Git PR AutopilotBotran on this pull request· 3 weeks ago

The reported Build web failure is no longer reproducible. Ran the web build with pnpm 9.15.9 and the same CI environment variables; Next.js compiled, type-checked, and generated all pages successfully. The existing test suite also passed in initial verification. Reverted the build-generated next-env.d.ts change, leaving the working tree clean; no code change was necessary.

No file changes were produced.

Triggered by check.failed

Automated run · @autopilot
All checks passed· 3 weeks ago· 8 checks
  • Apply migrations to a fresh PostgresPassed
  • Autopilot lifecycle against fresh PostgresPassed
  • Build webPassed
  • LintPassed
  • Schema drift (db:generate is up to date)Passed
  • TestsPassed
  • TypecheckPassed
  • drizzle-kit check (snapshot/journal consistency)Passed
This branch has conflicts that must be resolved
Resolve the conflicts manually, then push the branch to continue.
0 approving reviews
None yet
Checks
8/8 successful checks
Fast-forward
Source must contain the target branch tip
main ← feat/t3-env

You need push access to the source branch to update it.

Sign in to comment.

Merge readiness

Ahead2
Behind138
Fast-forwardBlocked
ConflictsYes

This branch has conflicts with the base branch that must be resolved.

Checks

Apply migrations to a fresh PostgresPassedAutopilot lifecycle against fresh PostgresPassedBuild webPassedLintPassedSchema drift (db:generate is up to date)PassedTestsPassedTypecheckPasseddrizzle-kit check (snapshot/journal consistency)Passed

Autopilot

Debug

Reviews

Approved0
ReviewersNone yet

Running Autopilot requires review access on this PR and push access to the source branch.

Latest runsuccess

The reported Build web failure is no longer reproducible. Ran the web build with pnpm 9.15.9 and the same CI environment variables; Next.js compiled, type-checked, and generated all pages successfully. The existing test suite also passed in initial verification. Reverted the build-generated next-env.d.ts change, leaving the working tree clean; no code change was necessary. No file changes were produced.

Fix PR Autopilot findings
6d5a4ca
View commits