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

@drzl/generator-trpc

v0.3.2

Published

Generate tRPC v11 routers from a Drizzle schema, one router per table, wired to DRZL's validation schemas.

Readme

@drzl/generator-trpc

Generate tRPC v11 routers from a Drizzle schema, one router per table, wired to the validation schemas DRZL already generates.

npm install -D @drzl/generator-trpc

@trpc/server is the consumer's own dependency; nothing here imports it. This package emits source text.

Use it through the CLI

// drzl.config.ts
export default {
  schema: 'src/db/schema.ts',
  outDir: 'src/api',
  generators: [{ kind: 'trpc', template: 'standard', includeRelations: true }],
};
drzl generate

Or with no config at all:

drzl generate:trpc src/db/schema.ts -o src/api

What lands on disk

| File | What it is | | --- | --- | | trpc.ts | the shared base: one initTRPC instance, Context, router, publicProcedure, createCallerFactory | | <table>.ts | one router per table | | index.ts | appRouter, and the AppRouter type your client is parameterised by |

// src/api/users.ts
import { z } from 'zod';
import { publicProcedure, router } from './trpc.js';

export const InsertusersSchema = z.object({ email: z.string() });
export const UpdateusersSchema = z.object({ email: z.string().optional() }).partial();
export const SelectusersSchema = z.object({ id: z.number(), email: z.string() });

export const usersRouter = router({
  list: publicProcedure.output(z.array(SelectusersSchema)).query(async () => {
    return [];
  }),
  byId: publicProcedure
    .input(z.object({ id: z.number() }))
    .output(SelectusersSchema.nullable())
    .query(async ({ input: _input }) => {
      return null;
    }),
  // ... create, update, delete
});

Serve it with any tRPC adapter:

import { createHTTPServer } from '@trpc/server/adapters/standalone';
import { appRouter } from './src/api/index.js';

createHTTPServer({ router: appRouter, createContext: () => ({}) }).listen(3000);

Procedures

list and byId are queries; create, update and delete are mutations. Every procedure declares an .output(...), which tRPC typechecks the handler's return against.

The primary key is read off your schema, at its real type and with every column of a composite key. A table with no primary key gets only list and create, rather than a fabricated id. A read-only relation gets only list and byId.

includeRelations adds one listBy<Column> query per single-column foreign key.

Use it directly if you prefer:

import { SchemaAnalyzer } from '@drzl/analyzer';
import { TRPCGenerator } from '@drzl/generator-trpc';

const analysis = await new SchemaAnalyzer('src/db/schema.ts').analyze({ includeRelations: true });
const { files } = await new TRPCGenerator(analysis).generate({ outputDir: 'src/api' });

Full documentation: https://use-drzl.github.io/drzl/generators/trpc

Generated Output License

You own the generated output. DRZL grants you a worldwide, royalty-free, irrevocable license to use, copy, modify, and distribute the generated files under your project's license.

License

Apache-2.0