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

prisma-api-gen

v1.2.1

Published

Generate grouped modules, routes, tests, and OpenAPI docs from your Prisma schema

Downloads

37

Readme

🛠 Prisma API Generator

npm version

This is a CLI tool for scaffolding module folders (service, controller, routes, schema) based on models in your schema.prisma. It supports optional grouping of models using @group comments for better folder organization.


📦 Installation

Run this in your project root:

npm link

⚠️ If you see an EEXIST error, remove the existing file:

sudo rm /usr/local/bin/npx prisma-api-gen
npm link

🚀 Usage

npx prisma-api-gen [options]

Options

| Option | Type | Default | Description | |---------------------|-----------|-------------|--------------------------------------------------------------------| | --model | string | | Generate module for a specific model name | | --all | boolean | false | Generate modules for all models in schema.prisma | | --new | boolean | false | Generate modules only for models without existing folders | | --output | string | src/modules | Target folder for module generation | | --withController | boolean | true | Whether to generate controller file | | --withRoutes | boolean | true | Whether to generate routes file | | --withSchema | boolean | true | Whether to generate Zod schema file | | --force | boolean | false | Overwrite existing files | | --dryRun | boolean | false | Simulate generation without writing any files |


🧩 Grouping Modules

Add a comment above your Prisma model like this:

/// @group billing
model Invoice {
  id        String   @id @default(uuid())
  total     Float
  createdAt DateTime @default(now())
}

This will generate a folder like:

src/modules/billing/invoice/

And update your src/modules/routes.ts automatically to include:

import invoiceRoutes from './billing/invoice/invoice.routes';
router.use('/invoice', invoiceRoutes);

💡 Examples

Generate all modules:

npx prisma-api-gen --all

Generate only missing ones:

npx prisma-api-gen --new

Generate a single model:

npx prisma-api-gen --model Booking

Dry run (preview changes):

npx prisma-api-gen --all --dryRun

Force overwrite:

npx prisma-api-gen --model Booking --force

📁 Output Structure

Each generated module includes:

model/
├── model.service.ts
├── model.controller.ts     (optional)
├── model.routes.ts         (optional)
└── model.schema.ts         (optional)

➕ Custom Routes

You can define additional routes per model by creating a custom-routes.json file in your project root.

Example:

{
  "User": [
    { "name": "disable", "method": "post", "path": "/:id/disable", "description": "Disable a user" }
  ]
}

This will generate:

  • A new controller.disable method

  • A route in router.post('/:id/disable', controller.disable);


📜 License

MIT