Drizzle
Drizzle support comes as a small companion package — @goldlapel/drizzle — alongside the core wrapper. Bring your own Drizzle and Postgres driver; Gold Lapel provides the proxy URL.
Install
npm install goldlapel @goldlapel/drizzle Two npm packages: goldlapel (the wrapper, spawns the proxy) and @goldlapel/drizzle (the integration helper). drizzle-orm and your Postgres driver of choice (pg is most common with Drizzle) stay yours to install.
Quick start (node-postgres)
Start the proxy with noConnect: true (your pg.Client owns the connection), then wire Drizzle to that client:
import { drizzle } from 'drizzle-orm/node-postgres';
import { Client } from 'pg';
import * as goldlapel from 'goldlapel';
// Spawn the proxy — noConnect skips Gold Lapel's internal driver connection
// (your pg client owns the connection)
const gl = await goldlapel.start(
'postgresql://user:pass@localhost:5432/mydb',
{ noConnect: true }
);
const client = new Client({ connectionString: gl.url });
await client.connect();
const db = drizzle(client);
const users = await db.select().from(usersTable);
await client.end();
await gl.stop(); Repeated reads serve in microseconds from Gold Lapel's L1 cache. Drizzle's query builder is unaffected.
With a schema
Pass Drizzle's options directly to drizzle() — schema, logger, anything else drizzle-orm/node-postgres accepts:
import { drizzle } from 'drizzle-orm/node-postgres';
import { Client } from 'pg';
import * as goldlapel from 'goldlapel';
import * as schema from './schema.js';
const gl = await goldlapel.start(process.env.DATABASE_URL, { noConnect: true });
const client = new Client({ connectionString: gl.url });
await client.connect();
const db = drizzle(client, { schema, logger: true }); Other drivers (postgres.js, Neon, etc.)
For drivers other than node-postgres, use wrapDrizzleDatasource(gl) to rewrite process.env.DATABASE_URL so whichever client you construct next picks up the proxy URL automatically:
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import * as goldlapel from 'goldlapel';
import { wrapDrizzleDatasource } from '@goldlapel/drizzle';
const gl = await goldlapel.start(process.env.DATABASE_URL, { noConnect: true });
// Rewrites process.env.DATABASE_URL to point at gl.url for any Drizzle driver
wrapDrizzleDatasource(gl);
const client = postgres(process.env.DATABASE_URL);
const db = drizzle(client); Why noConnect: true?
By default goldlapel.start() opens a small internal driver connection for the wrapper helpers (gl.search(), gl.docInsert(), etc.). When Drizzle is the only consumer, pass noConnect: true so Gold Lapel doesn't open a redundant connection. Drop the flag if you also want to use the wrapper helpers alongside Drizzle.
API
await goldlapel.start(upstream, opts?)
Factory from the core goldlapel package. Spawns the proxy and returns a GoldLapel instance. Pass noConnect: true when Drizzle is managing connections.
wrapDrizzleDatasource(gl)
Rewrites process.env.DATABASE_URL to point at gl.url. Useful when your Drizzle driver (postgres.js, Neon, PlanetScale, etc.) reads the connection string from the environment.
gl.url
Proxy connection string — pass it to your Postgres client directly, or let wrapDrizzleDatasource inject it into the environment.
gl.stop()
Stops the proxy. Idempotent, and runs automatically on process exit.
Options
Gold Lapel options live on goldlapel.start(). Drizzle options stay on drizzle():
const gl = await goldlapel.start('postgresql://user:pass@host:5432/mydb', {
noConnect: true,
port: 9000,
extraArgs: ['--threshold-duration-ms', '200'],
config: {
mode: 'waiter',
poolSize: 50,
},
}); | Option | Default | Description |
|---|---|---|
noConnect | false | Skip Gold Lapel's internal driver connection. Recommended when Drizzle is the only consumer. |
port | 7932 | Local proxy port |
extraArgs | [] | Extra CLI flags passed to the Gold Lapel binary |
config | {} | Structured config object (mode, poolSize, etc.) |
For the complete list of configuration keys, see the configuration reference.
Requirements
- Node.js 18+
- Drizzle ORM
- PostgreSQL (TCP connections)
For the underlying core wrapper API — goldlapel.start(), scoped connections, and the wrapper helpers — see the JavaScript guide.