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

@custom-generators/simple-prisma-dto-gen

v1.0.8

Published

Prisma generator for NestJS DTOs, enums and service scaffolding

Downloads

759

Readme

Simple Prisma DTO Gen

Prisma generator focused on NestJS projects.

It generates:

  • DTO classes for Prisma models
  • Insert DTO classes
  • Enum files
  • A DatabaseGenService with CRUD helpers
  • An optional PrismaService
  • A model.json file with the Prisma DMMF

Scope

This package is not a generic Prisma code generator.

Current assumptions:

  • DTOs import @nestjs/swagger
  • The optional generated PrismaService imports @nestjs/common
  • The optional generated PrismaService uses @prisma/adapter-mariadb (or @prisma/adapter-postgresql)
  • The generated service layer is designed for NestJS-style usage

Because of that, the package fits best in NestJS + Prisma projects.

Generated Output

Given an output directory, the generator creates:

<output>/
  dtos/
  insert.dtos/
  enums/
  service/
    database.gen.ts
    prisma.service.ts   # only when generatePrismaService = true
  model.json

Installation

Install the generator and Prisma:

npm install --save-dev prisma @custom-generators/simple-prisma-dto-gen
npm install --save @prisma/client @nestjs/swagger

Install these only if you want the generated PrismaService:

npm install --save @nestjs/common @prisma/adapter-mariadb mariadb dotenv

or

npm install --save @nestjs/common @prisma/adapter-postgresql dotenv

Prisma Schema Configuration

Example schema.prisma:

generator client {
  provider   = "prisma-client"
  output     = "../src/generated/prisma"
  engineType = "library"
}

generator classGenerator {
  provider                     = "npx simple-prisma-dto-gen"
  output                       = "../src/gen.dto"
  customPrismaClientImportPath = "src/generated/prisma/client"
  generatePrismaService        = true
  activeField                  = "active"
}

If you use Postgresql add :

databaseType = "postgresql"

Generator Options

  • output: target directory for generated files
  • customPrismaClientImportPath: import path used in generated service files
  • generatePrismaService: when true, generates service/prisma.service.ts; when false, DatabaseGenService depends directly on PrismaClient
  • activeField: when set, generated findOne* and findMany* methods filter by this field set to true, and generated delete* methods perform soft delete by setting this field to false

If activeField is not configured, generated delete* methods call Prisma delete().

Usage

Initialize Prisma if needed:

npx prisma init

Configure your database connection, then introspect or maintain your schema as usual:

npx prisma db pull

Run generators:

npx prisma generate

The provider value must be an executable command that Prisma can run. For this package, use the published bin command, not the npm package name. Using @custom-generators/simple-prisma-dto-gen directly will fail because Prisma tries to execute that exact string in the shell.

If you prefer, you can still use the explicit executable path as a fallback:

generator classGenerator {
  provider = "node node_modules/@custom-generators/simple-prisma-dto-gen/dist/bin.js"
}

NestJS Integration

If you generate PrismaService, load environment variables before the Nest app bootstraps:

import 'dotenv/config'

Example wrapper service:

import { Injectable } from "@nestjs/common"
import { DatabaseGenService } from "./gen.dto/service/database.gen"
import { PrismaService } from "./gen.dto/service/prisma.service"

@Injectable()
export class DatabaseService extends DatabaseGenService {
  constructor(prisma: PrismaService) {
    super(prisma)
  }
}

Register services in your module:

providers: [DatabaseService, PrismaService]

Example

For a Prisma model like:

model User {
  id    Int    @id @default(autoincrement())
  nome  String
  ativo Boolean @default(true)
}

The generator will produce files similar to:

  • dtos/user.dto.ts
  • insert.dtos/user.insert.dto.ts
  • service/database.gen.ts

And DatabaseGenService will include methods like:

  • findOneUser
  • findManyUser
  • createUser
  • updateUser
  • deleteUser

Limitations

  • The generated DTOs are tailored to NestJS Swagger usage
  • This package is intentionally opinionated and project-style driven