Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 1.62 KB

CLAUDE.md

File metadata and controls

42 lines (34 loc) · 1.62 KB

DBHub Development Guidelines

Commands

  • Build: pnpm run build - Compiles TypeScript to JavaScript
  • Start: pnpm run start - Runs the compiled server
  • Dev: pnpm run dev - Runs server with tsx (no compilation needed)

Environment

  • Copy .env.example to .env and configure for your database connection
  • Two ways to configure:
    • Set DSN to a full connection string (recommended)
    • Set DB_CONNECTOR_TYPE to select a connector with its default DSN
  • Transport options:
    • Set --transport=stdio (default) for stdio transport
    • Set --transport=sse for SSE transport with HTTP server

Database Connectors

  • Add new connectors in src/connectors/{db-type}/index.ts
  • Implement the Connector and DSNParser interfaces from src/interfaces/connector.ts
  • Register connector with ConnectorRegistry.register(connector)
  • DSN Examples:
    • PostgreSQL: postgres://user:password@localhost:5432/dbname
    • SQLite: sqlite:///path/to/database.db

Code Style

  • TypeScript with strict mode enabled
  • ES modules with .js extension in imports
  • Group imports: Node.js core modules → third-party → local modules
  • Use camelCase for variables/functions, PascalCase for classes/types
  • Include explicit type annotations for function parameters/returns
  • Use try/finally blocks with DB connections (always release clients)
  • Prefer async/await over callbacks and Promise chains
  • Format error messages consistently
  • Use parameterized queries for DB operations
  • Validate inputs with zod schemas
  • Include fallbacks for environment variables
  • Use descriptive variable/function names
  • Keep functions focused and single-purpose