@porulle/adapter-neon
v0.10.4
Published
Workers-grade Neon DatabaseAdapter for @porulle/core: HTTP driver for plain queries, a fresh WebSocket Pool per transaction, Hyperdrive-aware.
Readme
@porulle/adapter-neon
Workers-grade Neon DatabaseAdapter for @porulle/core.
Two transports, picked by query type — the design proven in production by porulle's first adopter (a live iPad POS on Cloudflare Workers + Neon):
- Plain queries go through
@neondatabase/serverlessHTTP — stateless, no socket-reuse races across Workers isolates. transaction()creates a fresh WebSocketPoolper call, runs the transaction, then ends the pool.drizzle-orm/neon-httpcannot run transactions, and isolate-shared WebSocket pools flake when reused across requests; a short-lived pool per transaction gives atomicity without the flake.
Usage
import { defineConfig } from "@porulle/core";
import { neonAdapter } from "@porulle/adapter-neon";
export default defineConfig({
databaseAdapter: neonAdapter({
connectionString: env.DATABASE_URL, // direct Neon URL
// Optional: route per-transaction pools through Hyperdrive
hyperdrive: env.HYPERDRIVE,
}),
// ...
});connectionString— direct Neon URL (postgresql://...neon.tech/...). Used by the HTTP driver, and by transaction pools when no Hyperdrive binding is given.hyperdrive— optional Cloudflare Hyperdrive binding (any object exposingconnectionString). When set, per-transaction pools connect through it; plain queries keep using the Neon HTTP driver againstconnectionString.
.execute() results are normalized to the postgres-js shape (an array of
rows), matching what @porulle/core and custom routes expect.
