npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@byebyebymyai/database-proxy-sdk-prisma

v1.0.0

Published

Prisma driver adapter for database-proxy Connect RPC (multi-datasource SQL gateway)

Downloads

33

Readme

@byebyebymyai/database-proxy-sdk-prisma

Prisma driver adapter that runs all SQL through database-proxy over Connect RPC. Use it when Prisma should talk to your databases only via the gateway (auth, audit, pooling, multi–data-source routing).

Requirements

  • Node.js 18+
  • Prisma ORM 6.6+ or 7.x (driver adapters) with matching @prisma/driver-adapter-utils (integration tests in this repo use Prisma 7 config layout)
  • A running database-proxy instance compatible with proto/sqlgateway/v1/sqlgateway.proto
  • By default the client uses Connect JSON over HTTP (same as curl with Content-Type: application/json). Set useBinaryFormat: true only if your server expects the binary codec.

Install

npm install @byebyebymyai/database-proxy-sdk-prisma

Peer dependencies (install in your app):

  • @prisma/client
  • @prisma/driver-adapter-utils

Prisma setup

  1. Set datasource.provider to the real SQL dialect behind the gateway (postgresql, mysql, etc.). Prisma still generates that dialect; the gateway only executes SQL.
  2. In Prisma 7, set datasource.url in prisma.config.ts to a syntactically valid URL for your provider (it can be a placeholder host; Prisma does not need a real TCP connection for prisma generate). Runtime SQL and migrations go through the adapter + gateway, not that URL.
  3. Pass DatabaseProxyAdapterFactory to PrismaClient as adapter.
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

model User {
  id   Int    @id @default(autoincrement())
  name String
}
import { PrismaClient } from "@prisma/client";
import { DatabaseProxyAdapterFactory } from "@byebyebymyai/database-proxy-sdk-prisma";

const prisma = new PrismaClient({
  adapter: new DatabaseProxyAdapterFactory({
    baseUrl: "http://127.0.0.1:8080",
    datasource: "dev",
    provider: "postgres",
  }),
});

Multiple datasources

Use one factory (or adapter) per logical datasource—for example two PrismaClient instances with different datasource ids, matching how you configure DATABASE_PROXY_DATABASES_JSON on the gateway.

Auth (JWT)

import {
  DatabaseProxyAdapterFactory,
  getAuthorizationBearerInterceptor,
} from "@byebyebymyai/database-proxy-sdk-prisma";

const prisma = new PrismaClient({
  adapter: new DatabaseProxyAdapterFactory({
    baseUrl: "https://gateway.example.com",
    datasource: "prod",
    provider: "postgres",
    interceptors: [getAuthorizationBearerInterceptor(() => process.env["GATEWAY_JWT"]!)],
  }),
});

For static headers (e.g. API keys), use getStaticHeadersInterceptor.

Migrations

executeScript sends the entire migration SQL in one gateway Execute call. Whether multi-statement scripts work depends on your database-proxy / JDBC backend (same as a single client batch).

For prisma migrate dev, set shadowDatasource on DatabaseProxyAdapterFactory to a second logical datasource id on the gateway that points at an isolated shadow database. Without it, connectToShadowDb throws. Never use the same datasource id as your main database.

Prisma + driver-adapter migrate remains sensitive to ORM version; this package is tested against the Prisma 7.x line used in this repo.

Updating generated RPC types

Protos are vendored under proto/ and compiled to src/gen/ with Buf.

npm run codegen

When upstream sqlgateway.proto changes, copy the file into proto/sqlgateway/v1/sqlgateway.proto, then run npm run codegen, bump the package version, and test.

Testing

  • Unit tests (CI default): npm test / npm run test:unit — runs vitest.config.ts (src/**/*.test.ts, test/unit/**/*.test.ts). No external services.
  • Typecheck including tests: npm run typecheck:test — runs prisma generate for the integration schema (placeholder URL in test/integration/prisma/prisma.config.ts), then tsc -p tsconfig.test.json.
  • Integration tests (local / manual CI): npm run test:integration — requires env vars and a live database-proxy; see test/integration/README.md. Migration-oriented checks (Connect JSON wire + executeScript) live in test/integration/migrations.integration.test.ts.

Scripts

| Script | Description | | ------------- | -------------------------- | | npm run build | Build ESM + CJS + types | | npm run test / test:unit | Unit tests (Vitest) | | npm run test:integration | Integration tests + Prisma generate | | npm run typecheck | tsc for src only | | npm run typecheck:test | tsc for src + tests | | npm run lint | Biome check | | npm run codegen | Regenerate src/gen |

License

MIT. See LICENSE.