Giter Site home page Giter Site logo

nestjs-prisma's People

Contributors

ali-master avatar donnguyen avatar gonza7aav avatar le-ar avatar liaosankai avatar loskir avatar marcjulian avatar megane42 avatar omar-dulaimi avatar sans-jmansfield avatar suryatmodulus avatar yicrotkd avatar yusupova avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nestjs-prisma's Issues

support Prisma v4

Hey, is there any intention to support Prisma 4 in the future, and if so, when?
We want to upgrade our platform, but nestjs-prisma has a peer-dependency with prisma versions "^2.0.0 || ^3.0.0"

Screen Shot 2022-07-18 at 14 59 59

Add support for fastify platform

Right now it's only possible to use this module with express, it would be great to have the ability to use all this with fastify since most of the source code would be the same.

 WARN  Issues with peer dependencies found
.
├─┬ nestjs-prisma 0.18.0
│ ├── ✕ missing peer @nestjs/platform-express@"^7.0.0 || ^8.0.0 || ^9.0.0"
├─┬ @nestjs/testing 8.4.6
│ └── ✕ missing peer @nestjs/platform-express@^8.0.0
└─┬ @nestjs/core 8.4.6
  └── ✕ missing peer @nestjs/platform-express@^8.0.0
Peer dependencies that should be installed:
  @nestjs/platform-express@">=8.0.0 <9.0.0" 

`response.status is not a function` when using PrismaClientExceptionFilter

I am using graphql and whenever I get any error (duplicate key, not found, ...) I get the following:

{
  "data": {},
  "errors": [
    {
      "message": "response.status is not a function",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "userCreate"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "stacktrace": [
          "TypeError: response.status is not a function",
          "    at ExpressAdapter.reply (C:\\Users\\Ryan\\Documents\\Projects\\Rhyno\\nest-rhyno-v2\\node_modules\\@nestjs\\platform-express\\adapters\\express-adapter.js:28:22)",
          "    at PrismaClientExceptionFilter.catch (C:\\Users\\Ryan\\Documents\\Projects\\Rhyno\\nest-rhyno-v2\\node_modules\\@nestjs\\core\\exceptions\\base-exception-filter.js:28:28)",
          "    at PrismaClientExceptionFilter.catchClientKnownRequestError (C:\\Users\\Ryan\\Documents\\Projects\\Rhyno\\nest-rhyno-v2\\node_modules\\nestjs-prisma\\lib\\prisma-client-exception.filter.ts:88:16)",
          "    at PrismaClientExceptionFilter.catch (C:\\Users\\Ryan\\Documents\\Projects\\Rhyno\\nest-rhyno-v2\\node_modules\\nestjs-prisma\\lib\\prisma-client-exception.filter.ts:69:19)",
          "    at ExternalExceptionsHandler.invokeCustomFilters (C:\\Users\\Ryan\\Documents\\Projects\\Rhyno\\nest-rhyno-v2\\node_modules\\@nestjs\\core\\exceptions\\external-exceptions-handler.js:34:32)",
          "    at ExternalExceptionsHandler.next (C:\\Users\\Ryan\\Documents\\Projects\\Rhyno\\nest-rhyno-v2\\node_modules\\@nestjs\\core\\exceptions\\external-exceptions-handler.js:13:29)",
          "    at Object.userCreate (C:\\Users\\Ryan\\Documents\\Projects\\Rhyno\\nest-rhyno-v2\\node_modules\\@nestjs\\core\\helpers\\external-proxy.js:14:42)"
        ]
      }
    }
  ]
}

I tried adding the filter by using APP_FILTER in my app.module.ts and also by using app.useGlobalFilters(new PrismaClientExceptionFilter(httpAdapter));

Specify non-default prisma client to import / use multiple prisma clients

Hi!

Is it possible to specify a different client (and therefore allow usage of multiple prisma clients)? I have two different schemata generating each into a separate directory using output in my schema.prisma-files:

generator client {
  provider = "prisma-client-js"
  output   = "prisma/client1"
  // output   = "prisma/client2"
}

I need to import those by addresing e.g.
import { PrismaClient } from '../prisma/client1';

It seems as if PrismaClient import within nestjs-prisma is directly tied to import { PrismaClient } from '@prisma/client';, which was ok if I use the default output. Is there any way to handle this more flexible?

Thanks in advance!

prisma.$on gives error

After updating to latest version 4.14.0 of prisma, the following error is coming. nestjs-prisma is 0.20.0

Error: Argument of type '"error"' is not assignable to parameter of type '"beforeExit"'
The error is only while using nestjs-prisma (PrismaService or CustomPrismaService)

image

In the above screenshot, you can see all option tried. The prisma1 is created directly and works.

Do guide further...

Provide Importable PrismaService

For our use case, we don't need to customize the PrismaService. Can this package provide simple importable PrismaService and PrismaModule?

@prisma/client did not initialize in Docker

when I remove the PrismaService from the app.module.ts the error message changes to:

Nest could not find PrismaService element (this provider does not exist in the current context)

This is true because I inject a custom Prisma service into my services. The code that causes this is in the main.ts file because of the shutdown hook.

import { PrismaService } from 'nestjs-prisma';
...
const prismaService: PrismaService = app.get(PrismaService);
await prismaService.enableShutdownHooks(app);

This seems an essential part to me but whenever I remove these two lines the error is gone and it all seems to work! Yay! But I still need to figure out how to put this shutdown hook back without destroying my apps.

Error: Collection "nestjs-prisma" cannot be resolved

nest add nestjs-prisma
✔ Package installation in progress... ☕
Starting library setup...
Error: Collection "nestjs-prisma" cannot be resolved.

Failed to execute command: node nestjs-prisma:nest-add --source-root="src" C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules@nestjs\cli\bin\nest.js add nestjs-prisma

Two different connections

Hi,

On my project I need to open 2 postgresql connections (1 master, 1 read replica for analytics). I can't figure how to give a custom name when I instantiate a PrismaModule that allow me to inject PrismaService with the specified name.

I need something like :
whatever.module.ts

@Module({
  imports: [
    PrismaModule.forRootAsync({
      name: 'ANALYTICS_DATABASE'
...

whatever.service.js

@Injectable()
export class WhateverService {
  @Inject("ANALYTICS_DATABASE")
  private readonly prismaAnalytics!: PrismaService;
...

Is that possible with your implementation ?

Thank you in advance

Nest can't resolve dependencies of the PrismaClientExceptionFilter (?, Object). Please make sure that the argument Object at index [0] is available in the AppModule context

Hi,
I'm getting the following error:

Nest can't resolve dependencies of the PrismaClientExceptionFilter (?, Object). Please make sure that the argument Object at index [0] is available in the AppModule context.

It happens when i try to use PrismaClientExceptionFilter provider, exactly like in the documentation.

My main.ts file:

import { HttpAdapterHost, NestFactory } from '@nestjs/core';
import { PrismaClientExceptionFilter, PrismaService } from 'nestjs-prisma';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  const { httpAdapter } = app.get(HttpAdapterHost);
  app.useGlobalFilters(new PrismaClientExceptionFilter(httpAdapter));

  const prismaService: PrismaService = app.get(PrismaService);
  prismaService.enableShutdownHooks(app);

  await app.listen(process.env.PORT);
}
bootstrap();

My app.module.ts

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { WorkspaceModule } from './workspace/workspace.module';
import { AuthModule } from './auth/auth.module';
import { PrismaClientExceptionFilter, PrismaModule } from 'nestjs-prisma';
import { APP_FILTER } from '@nestjs/core';

@Module({
  imports: [
    AuthModule,
    WorkspaceModule,
    PrismaModule.forRoot(),
  ],
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: APP_FILTER,
      useClass: PrismaClientExceptionFilter,
    },
  ],
})
export class AppModule {}

Complete error message:

[Nest] 8849  - 09/15/2022, 9:12:02 PM   ERROR [ExceptionHandler] Nest can't resolve dependencies of the PrismaClientExceptionFilter (?, Object). Please make sure that the argument Object at index [0] is available in the AppModule context.

Potential solutions:
- If Object is a provider, is it part of the current AppModule?
- If Object is exported from a separate @Module, is that module imported within AppModule?
  @Module({
    imports: [ /* the Module containing Object */ ]
  })

Error: Nest can't resolve dependencies of the PrismaClientExceptionFilter (?, Object). Please make sure that the argument Object at index [0] is available in the AppModule context.

Potential solutions:
- If Object is a provider, is it part of the current AppModule?
- If Object is exported from a separate @Module, is that module imported within AppModule?
  @Module({
    imports: [ /* the Module containing Object */ ]
  })

    at Injector.lookupComponentInParentModules (/home/kelvenrubalaine/Documents/projects/liberty-backend/node_modules/@nestjs/core/injector/injector.js:241:19)
    at Injector.resolveComponentInstance (/home/kelvenrubalaine/Documents/projects/liberty-backend/node_modules/@nestjs/core/injector/injector.js:194:33)
    at resolveParam (/home/kelvenrubalaine/Documents/projects/liberty-backend/node_modules/@nestjs/core/injector/injector.js:116:38)
    at async Promise.all (index 0)
    at Injector.resolveConstructorParams (/home/kelvenrubalaine/Documents/projects/liberty-backend/node_modules/@nestjs/core/injector/injector.js:131:27)
    at Injector.loadInstance (/home/kelvenrubalaine/Documents/projects/liberty-backend/node_modules/@nestjs/core/injector/injector.js:57:13)
    at Injector.loadProvider (/home/kelvenrubalaine/Documents/projects/liberty-backend/node_modules/@nestjs/core/injector/injector.js:84:9)
    at async Promise.all (index 4)
    at InstanceLoader.createInstancesOfProviders (/home/kelvenrubalaine/Documents/projects/liberty-backend/node_modules/@nestjs/core/injector/instance-loader.js:47:9)
    at /home/kelvenrubalaine/Documents/projects/liberty-backend/node_modules/@nestjs/core/injector/instance-loader.js:32:13

Someone help me?

Property '$on' is missing in type

I'm using a custom prisma client, and for some reason I'm getting TypeScript errors. They appear to be related to the prisma client type not matching the type in the package.

Here's my custom prisma module:

CustomPrismaModule.forRootAsync({
  name: 'PrismaService',
  useFactory: () => prismaClient,
  isGlobal: true,
}),

My custom prisma client:

import { PrismaClient } from '@prisma/database';
import { userSubscriptionIsActiveModelExtension, userSubscriptionIsActiveResultExtension } from './extensions';

export const prismaClient = new PrismaClient(
  process.env.NODE_ENV !== 'dev'
    ? {
        datasources: {
          db: {
            url: process.env.DATABASE_URL,
          },
        },
      }
    : undefined,
)
  .$extends(userSubscriptionIsActiveResultExtension)
  .$extends(userSubscriptionIsActiveModelExtension);

export type ExtendedPrismaClient = typeof prismaClient;

And here's the error:

Property '$on' is missing in type 'DynamicClientExtensionThis<TypeMap<Args & { result: { userSubscription: { isActive: () => { needs: { endsAt: true; isLifetime: true; paymentStatus: true; isOnFreeTrial: true; }; compute({ endsAt, isLifetime, paymentStatus, isOnFreeTrial }: { endsAt: Date | null; isLifetime: boolean; paymentStatus: StripePaymentStatu...' but required in type 'PrismaClientLike'.ts(2741)

When I comment out the $extends in the custom prisma client, the error goes away. I followed the documentation and it was working at one point. I'm not sure if one of the latest updates broke it? Here are my versions:

@prisma/client: 4.16.1
prisma: 4.16.1
nestjs-prisma: 0.20.1

Peer Dependency issues for @nestjs/common@"^10.0.0"

Hello,

I tried installing with the updated version of Nestjs but it failed.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: @nestjs/[email protected]
npm ERR! node_modules/@nestjs/common
npm ERR!   @nestjs/common@"^10.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @nestjs/common@"^7.0.0 || ^8.0.0 || ^9.0.0" from [email protected]
npm ERR! node_modules/nestjs-prisma
npm ERR!   nestjs-prisma@"*" from the root project

Prisma@3 regression in PrismaClientExceptionFilter

Hi, starting from 0.19.0, I found that support for prisma@3 was broken when using PrismaClientExceptionFilter.

0.19.0 introduced a new error type. But in prisma@3 there is no such error type. Thus, @Catch(...) is invoked with an undefined parameter. This leads to an app crash from Nestjs, because it doesn't anticipate an undefined parameter.

Here's a minimum reproduction code(based on a basic example from this repo, but using prisma@3). Simply call GET http://localhost:3000, and the app will crash, instead of responding with an error.

https://github.com/maxk096/nestjs-prisma-broken-v3

Error: Collection "nestjs-prisma" cannot be resolved.

Hello there,
Why I got this error? can I use another package manager like yarn for install the package? because installing 'nestjs-prisma' using other package manager it's normal
nestjs version: 8.2.1

PS C:\Users\richoandika\nestjs> nest add nestjs-prisma
✔ Package installation in progress... ☕
Starting library setup...
Error: Collection "nestjs-prisma" cannot be resolved.
    at NodeModulesEngineHost.resolve (C:\Users\richoandika\nestjs\node_modules\@angular-devkit\schematics\tools\node-module-engine-host.js:75:19)
    at NodeModulesEngineHost._resolveCollectionPath (C:\Users\richoandika\nestjs\node_modules\@angular-devkit\schematics\tools\node-module-engine-host.js:80:37)
    at NodeModulesEngineHost.createCollectionDescription (C:\Users\richoandika\nestjs\node_modules\@angular-devkit\schematics\tools\file-system-engine-host-base.js:118:27)
    at SchematicEngine._createCollectionDescription (C:\Users\richoandika\nestjs\node_modules\@angular-devkit\schematics\src\engine\engine.js:162:40)
    at SchematicEngine.createCollection (C:\Users\richoandika\nestjs\node_modules\@angular-devkit\schematics\src\engine\engine.js:155:43)
    at NodeWorkflow.execute (C:\Users\richoandika\nestjs\node_modules\@angular-devkit\schematics\src\workflow\base.js:101:41)
    at main (C:\Users\richoandika\tmp\nestjs\jam\node_modules\@angular-devkit\schematics-cli\bin\schematics.js:260:14)
    at Object.<anonymous> (C:\Users\richoandika\nestjs\node_modules\@angular-devkit\schematics-cli\bin\schematics.js:370:5)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)

Failed to execute command: node nestjs-prisma:nest-add --sourceRoot="src" C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\@nestjs\cli\bin\nest.js add nestjs-prisma

Docker template has error

You docker-compose.yml file includes an official postgres:12 image that needs some environment variables (see Environment Variables chapter on dockerhub Postgres page)
Environments provided by nestjs-prisma schematics nestjs-prisma/schematics/nestjs-prisma/templates/docker/.env
is incorrect:

POSTGRESQL_USER=prisma
POSTGRESQL_PASSWORD=topsecret
POSTGRES_DB=food

DATABASE_URL=postgresql://prisma:topsecret@postgresprisma:5432/food?schema=food&sslmode=prefer

must bee:

POSTGRES_USER=prisma
POSTGRES_PASSWORD=topsecret
POSTGRES_DB=food

DATABASE_URL=postgresql://prisma:topsecret@postgresprisma:5432/food?schema=food&sslmode=prefer

Also prisma 0.2.7 support dotenv-expand (see docs) which allows us to make the following improvement:

POSTGRES_USER=prisma
POSTGRES_PASSWORD=topsecret
POSTGRES_DB=food

DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgresprisma:5432/${POSTGRES_DB}?schema=food&sslmode=prefer

How can I log query params?

hello
I can't find way to handle emit type: 'event'.
thank you

PrismaModule.forRoot({
isGlobal: true,
prismaServiceOptions: {
// middlewares: [loggingMiddleware()],
prismaOptions: {
log: [
{ emit: 'stdout', level: 'query' },
{ emit: 'stdout', level: 'info' },
{ emit: 'stdout', level: 'warn' },
{ emit: 'stdout', level: 'error' },
],
},
},
}),

prisma:query BEGIN
[start:dev] prisma:query INSERT INTO team_seas.user (id,name,email,password,role) VALUES (?,?,?,?,?)

Error: "beforeExit" hook is not applicable to the library engine since Prisma 5.0.0, it is only relevant and implemented for the binary engine. Please add your event listener to the `process` object directly instead.

Today i tried to use this with new Prisma 5.0.0 and i noticed this error:

Error: "beforeExit" hook is not applicable to the library engine since Prisma 5.0.0, it is only relevant and implemented for the binary engine. Please add your event listener to the `process` object directly instead.
    at _t.on (/home/user/api/node_modules/@prisma/client/runtime/library.js:103:1990)
    at Proxy.$on (/home/user/api/node_modules/@prisma/client/runtime/library.js:126:5397)
    at Proxy.enableShutdownHooks (/home/user/api/node_modules/nestjs-prisma/lib/prisma.service.ts:42:10)
    at bootstrap (/home/user/api/src/main.ts:13:23)
which points to `main::bootstrap` function:
  // enable shutdown hook
  const prismaService: PrismaService = app.get(PrismaService);
  await prismaService.enableShutdownHooks(app);

Use of $extends

Hi

I want the service to always extends a specific extension I use

Currently I have to do something like this:

export const prismaClient = globalClient.$extends(
   fieldEncryptionExtension()
 )

Is there a way to do this with this package?

Errors coming using PrismaClientExceptionFilter at global level.

Errors coming using PrismaClientExceptionFilter at global level. Disable the use and all works well.

Error: TypeError: Right-hand side of 'instanceof' is not an object at is InstanceOf (node_modules/@nestjs/core/exceptions/exceptions-handler.js:28:54)

Following code is activated in request that causes the issue.

throw new BadRequestException({
                description: 'Insufficient Credential Details',
                status: HttpStatus.BAD_REQUEST,
});

Before upgrade to prisma 4.14.0, this worked well..!! nestjs-prisma is 0.20.0

When will nestjs 10 be supported?

nest add nestjs-prisma
▹▹▹▹▸ Package installation in progress... ☕
Failed to execute command: npm install --save nestjs-prisma@latest
✖ Package installation in progress... ☕
Unable to install library nestjs-prisma because package did not install. Please check package name.

npm install nestjs-prisma
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @nestjs/[email protected]
npm ERR! node_modules/@nestjs/common
npm ERR! @nestjs/common@"^10.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @nestjs/common@"^7.0.0 || ^8.0.0 || ^9.0.0" from [email protected]
npm ERR! node_modules/nestjs-prisma
npm ERR! nestjs-prisma@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!

### When will nestjs 10 be supported?

nest add nestjs-prisma error Cannot read properties of null (reading 'matches')

⠴ Installing packages (npm)...npm ERR! Cannot read properties of null (reading 'matches')

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/GWAPOKO/.npm/_logs/2023-01-19T07_57_49_031Z-debug-0.log
✖ Package install failed, see above.
The Schematic workflow failed. See above.

Failed to execute command: node nestjs-prisma:nest-add --source-root="src" /Users/GWAPOKO/.nvm/versions/node/v18.12.0/bin/node /Users/GWAPOKO/Library/pnpm/global/5/node_modules/@nestjs/cli/bin/nest.js add nestjs-prisma

Support for custom prisma locations

I have an issue with monorepo using npm workspaces and prisma. The set up is there are two microservices that both use prisma (say packages/api1, packages/api2). If the same version of prisma is used in each, npm will create https://github.com/prisma in the root node_modules. The generated .prisma files are installed as a sibling to https://github.com/prisma, so api1 and api2 can clobber each other. One can specify where to generate the files (https://www.prisma.io/docs/concepts/components/prisma-client/working-with-prismaclient/generating-prisma-client#using-a-custom-output-path), however, nestjs uses @prisma/client to import, so the new location is ignored.

Shutdown hooks

Does this package handle the shutdown hooks as described in the nest docs?
I can't find it when looking at the source code but maybe the documentation is outdated.

Add new graphql example

  • Add new nestjs project with name graphql under examples directory
  • Install GraphQL dependencies, Setup Prisma and nestjs-prisma
  • Add example resolver/services with PrismaService
  • Setup PrismaClientExceptionFilter
  • Add example to docs

PrismaClientExceptionFilter still throw 500

Hi Guys, i try example fastify from this library

and connect with my database, my service only like this :

  users() {
    return this.prisma.users.findFirstOrThrow({
      where: { user_id: 'My User Id' },
    });
  }

but reponse still throw error 500

{
    "statusCode": 500,
    "message": "Internal server error"
}

How to define prisma middlewares?

Is there a way to reach the underlying PrismaClient instance for using prismaClient.$use method or is there any other way to manipulate custom middlewares?

Nest can't resolve dependencies of the PrismaClientExceptionFilter

i am getting error when i am configure PrismaClientExceptionFilter in app.module.ts

[Nest] 32200 - 01/02/2023, 11:14:18 LOG [NestFactory] Starting Nest application...
[Nest] 32200 - 01/02/2023, 11:14:18 LOG [InstanceLoader] PrismaModule dependencies initialized +76ms
[Nest] 32200 - 01/02/2023, 11:14:18 ERROR [ExceptionHandler] Nest can't resolve dependencies of the PrismaClientExceptionFilter (?, Object). Please make sure that the argument Object at index [0] is available in the AppModule context.

Potential solutions:

  • Is AppModule a valid NestJS module?
  • If Object is a provider, is it part of the current AppModule?
  • If Object is exported from a separate @module, is that module imported within AppModule?
    @module({
    imports: [ /* the Module containing Object */ ]
    })

Error: Nest can't resolve dependencies of the PrismaClientExceptionFilter (?, Object). Please make sure that the argument Object at index [0] is available in the AppModule context.

Potential solutions:

  • Is AppModule a valid NestJS module?
  • If Object is a provider, is it part of the current AppModule?
  • If Object is exported from a separate @module, is that module imported within AppModule?
    @module({
    imports: [ /* the Module containing Object */ ]
    })
providers: [
    {
      provide: APP_FILTER,
      useClass: PrismaClientExceptionFilter,
    },
    AppService,
  ],

Use prisma db pull

Hi, I used PrismaModule.forRootAsync to set up my database URL. But it can't work when I ran prisma db pull in console. Should I still keep a .env file in my directory?

nestjs 8.0.0 support

Dear Marc,

Could you update peer dependencies for the package with the release of nestjs 8.0.0 please ?

Regards,

Maxerbox

Schematics fails in nest app version 9

Executing nest add nestjs-prisma in a Nest application using the latest version 9 returns following error:

nest add nestjs-prisma
▹▹▹▹▹ Package installation in progress... ☕
Failed to execute command: npm install --save nestjs-prisma@latest
✖ Package installation in progress... ☕
Unable to install library nestjs-prisma because package did not install. Please check package name.

could it be zero-dependency?

Hi,

I think, there is no problem with the following packages moving into devDependencies. Rather, so it can be made with zero-dependency. What do you think?

"dependencies": {
"@angular-devkit/core": "^13.3.0",
"@angular-devkit/schematics": "^13.3.0",
"@schematics/angular": "~13.3.0"
},

How to access $on in PrismaService?

Hi,
for the demo purpose I need to log queries fully like it's shown in this approach: prisma/prisma#5026 (comment).
How to do that?
On my opinion something like this should work:

import { NestFactory } from '@nestjs/core'
import { PrismaService } from 'nestjs-prisma'
import { AppModule } from '@/app.module'

async function bootstrap() {
  const app = await NestFactory.create(AppModule)
  const prismaService = app.get(PrismaService)
  await prismaService.onModuleInit()
  prismaService.$on('query', e => {
    console.log(e)
  })
  await app.listen(config.get('server.port'))
}
bootstrap()

It does not give any typescript error (PrismaService extends PrismaClient) but it does not log anything.

Generating docker-compose with wrong datasource

Hi, i noticed that the cli is creating a wrong datasource inside docker-compose.yml.

As you can see, i selected mysql as a datasource, but inside the docker-compose.yml file, it installed postgresql as a datasource

image

Angular schematics v14 fails with Nest v8

Current angular schematics v13 are working fine with Nest applications v8 and v9.

"@angular-devkit/core": "^13.3.0",
"@angular-devkit/schematics": "^13.3.0",
"@schematics/angular": "~13.3.0"

Updating to angular v14 still works fine with Nest v9, but applications with v8 are failing.

"@angular-devkit/core": "^14.0.6",
"@angular-devkit/schematics": "^14.0.6",
"@schematics/angular": "~14.0.6"

Error logs for installing nest add [email protected] in a Nest v8 app:

nest add [email protected]
✔ Package installation in progress... ☕
Starting library setup...
? Which datasource provider do you want to use for `prisma init`? sqlite
? Do you like to Dockerize your application? (Supports postgresql and mysql) No
    ✅️ Added prisma@latest
TypeError: this.host.readText is not a function
    at new JSONFile (nest-8-prisma/node_modules/@schematics/angular/utility/json-file.js:17:34)
    at addPackageJsonDependency (nest-8-prisma/node_modules/@schematics/angular/utility/dependencies.js:27:18)
    at nest-8-prisma/node_modules/nestjs-prisma/schematics/nestjs-prisma/index.js:40:57
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)
    ✅️ Added @prisma/client@latest

prisma-client-exception filter

Hello there,

Problem

nestjs-prisma error filter is handling only PrismaClientKnownRequestError

Solution

Handling other client error types such as :

PrismaClientInitializationError
PrismaClientRustPanicError
PrismaClientUnknownRequestError
PrismaClientValidationError

do you want me to raise PR for this issue :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.