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

@lootupteam/nestjs-prisma

v1.1.2

Published

A utility for working with Prisma in NestJS. This package offers abstraction and a dedicated implementation that can be extended with a custom class.

Readme

NestJs Prisma

npm version License

Overview

@lootupteam/nestjs-prisma - is a library designed to simplify the integration of Prisma ORM into NestJS applications. It provides base classes, utilities, and extensions to make working with Prisma more convenient and type-safe.

Features

  • Prisma Service: The base abstract class PrismaService for working with Prisma Client. Provides logging and access to Prisma Client.
  • Prisma Module: NestJS module for registering and configuring Prisma. Supports asynchronous configuration.
  • Dependency Injection: Convenient decorators and methods for injecting PrismaService into application components.
  • Custom Adapters: The ability to use the implementation principles of PrismaService to extend functionality.

Installation

npm install @lootupteam/nestjs-prisma @prisma/client prisma
# or
pnpm add @lootupteam/nestjs-prisma @prisma/client prisma
# or
yarn add @lootupteam/nestjs-prisma @prisma/client prisma

Getting Started

  • Import and Configure PrismaModule: In your AppModule (or any other module), import and configure PrismaModule:
// src/app.module.ts
import { Module } from '@nestjs/common';
import { PrismaModule } from '@lootupteam/nestjs-prisma';
import { PrismaClient } from '@generated/prisma/client'; // Your path to generated Prisma
import { AppService } from './app.service';

@Module({
  imports: [
    PrismaModule.forRootAsync({
      // Use forRootAsync for better configuration
      useFactory: () => ({
        instance: new PrismaClient({
          // Configure PrismaClient
          log: [{ level: 'query', emit: 'event' }], // Enable query logging
        }),
        debug: true, // Enable debug mode
      }),
    }),
  ],
  providers: [AppService],
  controllers: [],
})
export class AppModule {}
  • Inject PrismaService: Inject PrismaService (or your extended service) into your services or controllers:
// src/app.service.ts
import { Injectable } from '@nestjs/common';
import { PrismaClient } from '@generated/prisma/client'; // Your path to generated Prisma
import { InjectPrisma, PrismaService } from '@lootupteam/nestjs-prisma'; // Import InjectPrisma decorator and PrismaService
// import { ExtendedPrismaService } from './extended-prisma.service';  // If you have custom service

@Injectable()
export class AppService {
  constructor(
    @InjectPrisma() private readonly prismaService: PrismaService<PrismaClient>, // Inject PrismaService using decorator
    // @InjectPrisma() private readonly prismaService: ExtendedPrismaService, // Inject custom service
  ) {}

  async getUsers() {
    return this.prismaService.getClient().user.findMany();
  }

  // Use prismaService.getClient() to access PrismaClient directly
  async createUser(email: string, name: string) {
    return this.prismaService
      .getClient()
      .user.create({ data: { email, name } });
  }
}

Advanced Usage

Using Custom Prisma Services

  • Create a Custom Service (e.g., ExtendedPrismaService): Create a class that extends PrismaService:
// src/extended-prisma.service.ts
import { Injectable, Logger } from '@nestjs/common';
import {
  PrismaService,
  PrismaModuleOptions,
  MODULE_OPTIONS_TOKEN,
} from '@lootupteam/nestjs-prisma';
import { PrismaClient } from '@generated/prisma/client'; // Your path to generated Prisma
import { Inject } from '@nestjs/common';

@Injectable()
export class ExtendedPrismaService extends PrismaService<PrismaClient> {
  constructor(
    @Inject(MODULE_OPTIONS_TOKEN)
    protected readonly options: PrismaModuleOptions<PrismaClient>,
  ) {
    super(options);
  }

  async getTemplatesByOwner(ownerId: string) {
    const prisma = this.getClient();
    return prisma.template.findMany({ where: { ownerId } });
  }
}
  • Register the Custom Service: Register a custom service in PrismaModule using forRootAsync:
// src/app.module.ts
import { Module } from '@nestjs/common';
import { PrismaModule } from '@lootupteam/nestjs-prisma';
import { PrismaClient } from '@generated/prisma/client'; // Your path to generated Prisma
import { AppService } from './app.service';
import { ExtendedPrismaService } from './extended-prisma.service';

@Module({
  imports: [
    PrismaModule.forRootAsync({
      useFactory: () => ({
        instance: new PrismaClient({
          log: [{ level: 'query', emit: 'event' }],
        }),
        debug: true,
        customService: ExtendedPrismaService, // use ExtendedPrismaService
      }),
    }),
  ],
  providers: [AppService],
  controllers: [],
})
export class AppModule {}
  • Inject the Custom Service: Inject the custom service into your component:
// src/app.service.ts
import { Injectable, Inject } from '@nestjs/common';
import { PrismaService, InjectPrisma } from '@lootupteam/nestjs-prisma';
import { ExtendedPrismaService } from './extended-prisma.service';

@Injectable()
export class AppService {
  constructor(
    @InjectPrisma() private readonly prismaService: ExtendedPrismaService, // Inject ExtendedPrismaService
  ) {}

  async getUsers() {
    return this.prismaService.getClient().user.findMany();
  }
}

Contributing

Contributions are welcome! Feel free to submit pull requests or open issues.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For any questions or issues, please open an issue in this repository.