Platform-native bindings (Cloudflare R2/D1/KV, Azure Storage contexts,
etc.) are not representable as strings, so getEnv() can't carry them.
Add a typed getBinding<T>() accessor: returns the binding on platforms
that support it, undefined on others.
Callers branch on the return — e.g. \`getBinding<R2Bucket>('PUBLIC_IMAGES')\`
will be defined on CF and undefined on Node/Docker, letting the same
code pick a runtime-appropriate path without platform-specific imports.
Used in the next commit to switch the public image upload flow to R2
binding on CF (zero-auth, zero-egress) while keeping the S3 fallback
for every other platform.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace all db.all(sql`...`) / db.run(sql`...`) calls with Drizzle's
type-safe query builder (select/insert/update/delete). Schema changes
now trigger TypeScript errors in queries, and column name typos are
caught at compile time.
- Unify Database type to BaseSQLiteDatabase for query builder compat
- Derive Matter/Storage types from schema via $inferSelect
- Use inArray() instead of manual sql.join() for IN clauses
- Net -90 lines across 9 files
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>