refactor: type the drizzle client for real - #5
Open
fengmk2 wants to merge 1 commit into
Open
Conversation
Replace @cnode/db's escape hatch (export type DB = any) with the real drizzle client type, plus a Database alias (PgDatabase over the schema) for helpers that only run queries, so they accept the client, a transaction, or drizzle.mock() in tests. All surfaced type errors are fixed without changing any JSON response: - transaction callbacks rely on inference instead of tx: DB annotations - insertReply returns the narrowed ReplyForCreation shape - password compares guard pass being null (GitHub-only accounts) and keep answering 403 - nullable row fields feeding non-null contract slots are coalesced (?? "" / ?? 0 / ?? undefined) and Date fields serialize explicitly via toISOString, which JSON.stringify already produced on the wire - /messages keeps emitting the empty topic.author placeholder it always produced; populating it for real is a behavior change split into the next stacked layer - the reply-data-consistency test mocks drizzle with the exact schema namespace now exported from @cnode/db
fengmk2
force-pushed
the
enable-typed-db
branch
from
August 5, 2026 07:55
a3e2b0a to
09fc0d9
Compare
fengmk2
marked this pull request as ready for review
August 5, 2026 08:35
thonatos
approved these changes
Aug 5, 2026
thonatos
left a comment
Member
There was a problem hiding this comment.
Review: LGTM
消灭 DB = any,拆 DB/Database 两面,事务 tx 获得真实类型;顺带修复 GitHub 账号 user.pass 为 null 时登录/改密崩溃等真 bug。
非阻塞:
- 可空时间字段序列化不一致:
create_atnull→"",而last_reply_at/update_at保留null,建议统一。 - 消息列表
reply缺省值{}→{id:"",content:"",ups:[],create_at:""},属 wire 变化,前端需知悉。
11 tasks
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
OpenSpec
<!-- change name -->Verification
pnpm verifypassed.<!-- commands -->because<!-- reason -->.Impact Checklist
apps/,packages/)apps/api/src/routes/*.tszod-openapi declarations,api/openapi.jsonviapnpm gen:openapi)packages/db)deployment/)README.md,docs/,wiki/).github/workflows/,scripts/,package.json).env, tokens, cookies, private keys, database URLs, or user data committed.Migration / Deployment Notes