refactor: codex compliance — type safety, validation, sync correctness#115
Merged
Conversation
|
🧹 Preview cleaned up — PR merged! The preview worker has been deleted. |
- add shared type definitions (src/lib/types.ts) for D1 entities - add fetch-with-timeout utility with AbortController pattern - add Zod schemas for API input validation - integrate zValidator middleware into photos-api admin routes - add structured logging (logSync) to cron.ts sync operations - configure Notion client with 15s timeout - add fetch timeouts for image downloads (10s) - export CloudflareEnv from env.d.ts for type inference - remove (env as any) casts throughout codebase - use ClimbListItem type in climbs.astro for proper typing
store notion_id for climbs/peaks/gear (was silently null, breaking body sync) and report accurate insert vs update counts. extract parsing helpers into src/lib/notion-helpers.ts so the cron sync and unit tests share one implementation, and fix parseAreaFallback to preserve internal hyphens (e.g. Bridger-Teton). add vitest and unit tests covering the helpers.
0 errors / 0 warnings from astro check. - pages/components: type DOM queries as HTMLElement, add null guards, type D1 .first() rows, narrow filtered arrays (index, peaks, admin/climbs, blog, about, ClimbTable). - config/scripts: drop the removed platformProxy adapter option, import z from astro/zod, widen the seed generic, assert the BGE embedding shape. - remove unused imports and vars (APIErrorCode, MAX_CUSTOM_WIDTH, mock params).
adds biome (dep, biome.json, lint/lint:fix scripts) tuned to the repo style (single quotes, no semicolons, 2-space, 100 cols). not yet applied repo-wide; run 'npm run lint:fix' after this lands.
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
Hardens the Notion→D1 sync and photos API for type safety, input validation, and error handling, then drives the codebase to a clean `astro check` (0 errors / 0 warnings) and scaffolds Biome for linting. Built on the original codex-compliance work; the last two commits squash-merge the type-error cleanup and lint setup.
Key Changes
src/pages/api/cron.ts): storenotion_idfor climbs/peaks/gear (was silently NULL, breaking body sync), report accurate insert-vs-update counts, and extract shared parsing helpers intosrc/lib/notion-helpers.ts(also fixesparseAreaFallbackmangling hyphenated areas likeBridger-Teton).src/env.d.ts): merge bindings into the globalCloudflare.Envinterface soenv.DB/R2_IMAGES/IMAGESresolve everywhere (cleared ~26 errors).utils/photos-api.ts, route files): validate theGET /api/photosquery with Zod, dedupe Zod error formatting, build the Hono app once per isolate instead of per request.merge: type errs): typed DOM queries asHTMLElement+ null guards in client scripts (index, peaks, admin/climbs, blog, about), typedD1.first()rows, narrowed filtered arrays, dropped the removedplatformProxyadapter option,zfromastro/zod, widened the seed generic, asserted the BGE embedding shape.tests/,vitest.config.ts): vitest + 36 unit tests covering the extracted sync helpers (imported, not duplicated).merge: lint): Biome dep + config +lint/lint:fixscripts, tuned to repo style. Not yet applied repo-wide.Test Steps
npm test→ 36/36 passnpx astro check→ 0 errors, 0 warnings (4 pre-existing.mjshints remain)npm run build→ completes/,/peaks(filter buttons),/about, a blog post — render with no console errors (verified locally after seeding D1)Risks / Follow-ups
npm run lint:fixfor Biome's first repo-wide format pass (deliberately deferred to keep this diff reviewable).notion_idbackfill depends on migrations0006/0007being applied to remote D1.scripts/migrate/*.mjs(unrelated tooling; left untouched).astro checkrequires@astrojs/check(already installed locally); not added to deps here.