@nwire/data-drizzle
v0.7.1
Published
Nwire — Drizzle ORM adapter. Provider that registers a Drizzle client on the container, manages the connection pool lifecycle, and exposes optional readiness checks + telemetry. No Repository wrapper — handlers get the real Drizzle API.
Readme
@nwire/data-drizzle
Drizzle ORM provider — lifecycle-managed
dbclient handlers import directly.
What it does
Boots a Drizzle ORM client as a Nwire provider so handlers can use the real Drizzle API (full end-to-end TypeScript inference) without DI ceremony. Pluggable health check + telemetry emit on every query. Pairs with pglite for zero-Docker tests.
Install
pnpm add @nwire/data-drizzle drizzle-ormQuick start
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
import { drizzleProvider } from "@nwire/data-drizzle";
import { defineApp, defineAction } from "@nwire/forge";
import * as schema from "./schema.js";
import { db } from "./db.js";
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
export const drizzleDb = drizzle(pool, { schema });
defineApp("my-app", {
modules: [...],
providers: [drizzleProvider({ db: drizzleDb, close: () => pool.end() })],
});
// In a handler — import db directly:
defineAction({
name: "users.create",
handler: async ({ input }) => {
const [user] = await db.insert(users).values(input).returning();
return user;
},
});API surface
drizzleProvider({ db, close?, check? })— provider definition; lifecycle-managed.
When to use
When you want a typed SQL layer with end-to-end inference.Compose with @nwire/auth-better-auth
Within nwire-app
For developers using this package as part of the Nwire stack — register it via app.use(...) or it auto-wires when you compose createApp({ modules }).
import { createApp } from "@nwire/forge";
const app = createApp({
/* ...config... */
});
// Adapter/plugin wiring happens here when applicable.