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-model-cli

v1.2.51

Published

Generate service/controller/routes for Prisma models

Downloads

7

Readme

📦 PrismaGen CLI

PrismaGen is a flexible CLI tool that auto-generates a scalable API structure from your schema.prisma file.

Supports:

  • ✅ NestJS (TypeScript)
    • REST API
    • GraphQL API
  • ✅ Express (TypeScript or JavaScript)
  • ✅ GraphQL (TypeScript or JavaScript)
  • ✅ TypeScript API Client via Swagger/OpenAPI

🚀 Installation

npm install -g prisma-model-cli

install locally:

npm install prisma-model-cli

🔧 Usage

prismagen

You can also use flags to skip the interactive dialog:

▶️ CLI Options

NestJS Options

| Command | Description | | ----------------------------------------- | ---------------------------------------------------------- | | prismagen --nestjs | Generate NestJS REST API structure (TypeScript) | | prismagen --nestjs --no-swagger | Generate NestJS REST API without Swagger setup | | prismagen --nestjs --graphql | Generate NestJS GraphQL API structure (TypeScript) | | prismagen --nestjs --graphql --no-swagger | Generate NestJS GraphQL API without Swagger setup |

Express Options

| Command | Description | | --------------------------------- | ---------------------------------------------------------- | | prismagen --express | Generate Express API structure (TypeScript) | | prismagen --express --output-js | Generate Express API structure (JavaScript) |

GraphQL Options

| Command | Description | | --------------------------------- | ---------------------------------------------------------- | | prismagen --graphql | Generate GraphQL API structure (TypeScript) | | prismagen --graphql --output-js | Generate GraphQL API structure (JavaScript) |

Swagger/OpenAPI Options

| Command | Description | | --------------------------------- | ---------------------------------------------------------- | | prismagen generate swagger | Generate NestJS REST + Swagger UI TypeScript client | | prismagen generate swagger --graphql | Generate NestJS GraphQL + Swagger UI TypeScript client |

General Options

| Command | Description | | --------------------------------- | ---------------------------------------------------------- | | prismagen --help or -h | Show CLI help | | prismagen --version or -v | Show installed version |


📁 Output Structure

NestJS REST API Structure

models/
  └── user/
      ├── user.controller.ts
      ├── user.service.ts
      ├── dto/
      │   ├── create-user.dto.ts
      │   └── update-user.dto.ts

NestJS GraphQL API Structure

models/
  └── user/
      ├── user.resolver.ts
      ├── user.service.ts
      ├── dto/
      │   ├── create-user.input.ts
      │   └── update-user.input.ts
      └── user.types.ts

Express API Structure

models/
  └── user/
      ├── user.controller.ts
      ├── user.service.ts
      └── routes/
          └── user.routes.ts

GraphQL API Structure

models/
  └── user/
      ├── user.resolver.ts
      ├── user.service.ts
      ├── user.types.ts
      └── user.inputs.ts

🧬 Generate Swagger TypeScript Client

To generate a TypeScript SDK using openapi-generator-cli from your running NestJS Swagger endpoint:

prismagen generate swagger

For GraphQL API:

prismagen generate swagger --graphql

You'll be prompted to:

  1. Enter the Swagger JSON URL (defaults to http://localhost:3000/api-json)
  2. Choose the output directory (defaults to ../client/src/app/api)

The CLI will:

  • Run NestJS model generation via run.ts
  • Validate the Swagger endpoint is reachable
  • Generate a TypeScript Axios client via OpenAPI Generator

⚙️ Prerequisites

Ensure your project has:

  • Prisma installed and set up:

    npm install prisma @prisma/client
    npx prisma init
  • A valid schema.prisma in /prisma/schema.prisma

Run:

npx prisma generate

🧠 How It Works

  1. Parses all models from your Prisma schema.
  2. Generates base CRUD logic (BaseController, GenericPrismaService).
  3. Outputs language-specific files based on the selected mode.
  4. Optionally, generates a Swagger client using openapi-generator-cli.

🛠 Dev Setup (if modifying CLI)

  1. Clone this repo

  2. Build the CLI:

    npm install
    npm run build
  3. Link it globally to use prismagen from anywhere:

    npm link

🧩 Future Features

  • Support for custom middleware
  • Soft deletes
  • Swagger docs out of the box
  • Authentication scaffolding (JWT, session-based)

📬 Issues / Contributions

Open issues or PRs on GitHub

We welcome contributions!