hacker news Hacker News
  1. new
  2. show
  3. ask
  4. jobs
I built KnexBridge to fix a long-standing pain in Knex projects — keeping TypeScript types and runtime validation in sync with your database schema.

KnexBridge introspects your DB and auto-generates:

- bridge.schema.ts → strongly-typed table definitions - bridge.validation.ts → matching Zod schemas

SQLite is supported now; PostgreSQL and MySQL are next.

Usage: npx knexbridge generate

Example output: export const users = z.object({ id: z.number(), email: z.string(), created_at: z.date(), }); export type User = z.infer<typeof users>;

Repo: https://github.com/Neon-Nomad/KnexBridge npm: https://www.npmjs.com/package/knexbridge Core: https://www.npmjs.com/package/knexbridge-core

Roadmap: • PostgreSQL + MySQL • Watch mode • OpenAPI + JSON Schema output • Plugin system

Would love feedback from anyone using Knex with TypeScript or Zod. Always open to PRs or ideas.

loading...