chore(dev-env): load .env via tsx + seed sheet configs#21
Merged
Conversation
Two small fixes that together let `npm run dev` boot the API on a fresh checkout (previously the api crashed at boot because @fastify/env couldn't find required vars and openPublicStore threw config_missing for every declared sheet): 1. `apps/api/dev` script now passes `--env-file=../../.env` to tsx so the repo-root .env is loaded into process.env before @fastify/env validates. Node 22+ supports --env-file natively; no new dependency. 2. New `apps/api/scripts/setup-dev-data.ts` (npm script: `script:setup-dev-data`) seeds an empty data repo with the minimal `[gitsheet]` blocks for each of the 11 sheets declared in `apps/api/src/store/public.ts`. Idempotent — skips configs that already exist. The path templates are dev-stub defaults documented in the script; the data repo is empty at this stage so they don't need to be the production-canonical templates. `.env.example` updated to point at the new setup script and to note that relative paths are resolved from apps/api/ (not the repo root, which the old comment misleadingly implied). `.gitignore` updated to ignore `apps/codeforphilly-data/` (where the dev data repo lands by default), `codeforphilly-data/` (in case someone uses an absolute path or differs the layout), and `.claude/worktrees/` (where background agent worktrees live). Verified locally: `cp .env.example .env`, `npm run -w apps/api script:setup-dev-data`, `npm run dev` — both web (:5173) and api (:3001) come up; `GET /api/health` returns the documented envelope. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small fixes so
npm run devboots the API on a fresh checkout:.envauto-load —apps/api/devscript now passes--env-file=../../.envto tsx. Node 22+ feature; no new dep.apps/api/scripts/setup-dev-data.ts(npm run -w apps/api script:setup-dev-data) seeds an empty data repo with the 11 sheet configsopenPublicStoredeclares. Idempotent; safe to re-run.Plus a documentation fix in
.env.example(the old comment said paths are "relative from repo root" but the API resolves them fromapps/api/), and.gitignoreupdates to ignore the dev data repo and agent worktree directories.Caught while trying to hand a working dev URL to a reviewer mid-session — neither gap was caught in the
api-skeletonplan's Validation since the boot path wasn't exercised against an actual filesystem there.Test plan
cp .env.example .env(withCFP_JWT_SIGNING_KEYfilled in)npm run -w apps/api script:setup-dev-datacreates the data repo + 11.gitsheets/<name>.tomlfiles + commits themnpm run devboots both apps; api on :3001, web on :5173curl http://localhost:3001/api/healthreturns the documented envelope🤖 Generated with Claude Code