You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix server type errors after dual-driver; swap postgres.js → node-postgres (#32)
Background: the dual-driver commit (#29) typed the exported `db` as
`NeonHttpDatabase | PostgresJsDatabase`, which degraded every
`.returning()` / `.execute().rows` call site via builder-chain
signature intersection — 60+ ghost type errors across the modules.
Fixes:
- db.ts: narrow `db` to `NeonHttpDatabase<typeof schema>` (the production
driver and the shape the codebase was written against). Type-level also
enforces the no-transactions rule documented in apps/server/CLAUDE.md.
- db.ts: swap the local-Postgres branch from `postgres.js` to `pg` via
`drizzle-orm/node-postgres`. `pg`'s `{ rows, fields, rowCount }` result
matches `NeonHttpQueryResult` natively, dropping the `.rows` shim,
timestamp OID serializers, and `prepare: false` workarounds. Pin UTC
at connection startup via libpq `options: "-c TimeZone=UTC"`.
- env-bindings.d.ts: augment `Cloudflare.Env` with the 8 secrets wrangler
can't infer (DATABASE_URL, BETTER_AUTH_*, UPSTASH_*, TINYBIRD_*).
- env.ts + require-client-credential.ts: add `ClientCredentialContext`
and set `c.var.clientCredential` in the middleware, previously referenced
but not wired.
- middleware/session.ts: normalize `activeOrganizationId: undefined → null`
to match `InferredSession` (Better Auth types it as optional).
- task/client-routes.ts: pass `credential.publishableKey` to
`verifyRequest` — previously passed the whole object, which didn't
match the `(publishableKey: string, ...)` signature.
- item/validators.ts: `UseItemResponseSchema.costItems`/`rewardItems`
take the polymorphic `RewardEntry` shape, matching what `PullResult`
actually returns since the currency refactor (#30).
- middleware/request-log.ts: guard `c.executionCtx` — it's workerd-only
and throws under vitest/Node, which was silently breaking every
route-layer test since the Tinybird commit (#31).
ESLint cleanup:
- Disable `no-unused-vars` (both variants) in the shared base + re-apply
in react-internal.js (tseslint preset re-enables it after base).
- Disable `react/prop-types` — TypeScript handles prop validation.
- Give `*.config.{js,mjs,cjs,ts}` the Node globals so `process` isn't
`no-undef` in tinybird.config.mjs.
- Declare TINYBIRD_* in turbo.json globalEnv.
- `eslint --fix` picked up 4 prefer-const and 3 stale eslint-disable
directives across services and tests.
Verified: `pnpm --filter=server check-types` / `lint` / `test` all
green (618/618 tests, up from 591 before the request-log guard).
0 commit comments