Have installed graphql-upload, do import { graphqlUploadExpress } from ‘graphql-upload’; And getting this error: Error: No “exports” main defined in graphql-upload/package.json Dependencies: The version of node: v16.10.0 Answer So the problem was in the .default build settings. You can remove it, but when we removed it we saw the problem with other modules, so we resolved this issue via this:
Tag: nestjs
Javascript Mocking functions that return Readable
I have a simple function that calls my s3 service which will return a Promise I would like to mock the return of the object and assert it in the test like this: When i run the test, I face this error: Error [ERR_METHOD_NOT_IMPLEMENTED]: The _read() method is not implemented at Readable.read (internal/streams/readable.js:642:9) at Readable.read (internal/streams/readable.js:481:10) at maybeReadMore (internal/streams/readable.js:629:12) at
Reading PORT number from .env file in nestjs
I have details defined in .env file. Below is my code. host: process.env.SMTP_HOST is working properly. but when I am writing process.env.SMTP_PORT it is saying you can not assign string to number. when I wrote parseInt(process.env.SMTP_PORT) it is still not working. how to assign port from .env file Answer port: +process.env.SMTP_PORT should work casting it to a number. If there
NestJS and TypeORM Exception Filter: Get Status is not a function
I’m developing an app using NestJS and TypeORM. My goal is to catch TypeORM errors and it could be done using exception filters. But my problem is, I’m encountering this error: (node:345) UnhandledPromiseRejectionWarning: TypeError: exception.getStatus is not a function This is similar to this github post discussing the problem but it’s not working on my end. Here’s my setup: I’ve
ERROR [ExceptionsHandler] Invalid `prisma.executeRaw()` invocation: ERROR [ExceptionsHandler] Invalid `prisma.executeRaw()` invocation:
my Stored procedure CREATE OR REPLACE PROCEDURE public.transfer_transactions( initiated_by integer, OUT transaction integer) LANGUAGE ‘plpgsql’ AS $BODY$ $BODY$; Calling the sp from nestjs prisma client async create(createTransactionDto: CreateTransactionDto) { const [callGetSequenceBlock, queryString] = await this.prisma.$transaction([ this.prisma.$executeRawCALL transfer_transactions(${login_id},@transaction);, this.prisma.$queryRawSELECT @transaction FROM DUAL;, ]); } error displayed while executing API Invalid prisma.executeRaw() invocation: Raw query failed. Code: 42703. Message: column “transaction_idout” does
ERROR [ExceptionHandler] No repository for “Product” was found. Nest.js
I am trying to register and migrate a new entity (Nest.js) but it fails with the following error text: product.entity.ts product.module.ts Any ideas? Answer You could use the auto load entities feature to circumvent that. (like I said on discord)
Nested object in Joi schema
I’ve defined validation schema via Joi with nested object in AWS value: Then I put my schema to config module I’ve added inside .env file the next value for AWS variable: but I got the next error message after starting nest: typeof process.env.AWS returns a string and Joi doesn’t understand that he should parse it, maybe I need to add
How @Inject(REQUEST) works and how to destructure it
The first question is how it’s possible that an injected parameter is changing after the class initialization. Because this code works and this code doesn’t work The second example doesn’t have ‘userId’ yet that should be injected by my nest.js interceptor. Why it’s like that if both of those code snippets are identical? Even if the request variable only points
ValidationPipe doesn’t strip given object in Nestjs
I’m using Nestjs and Mongoose orm the problem is ValidationPipe doesn’t delete invalid props from request and send given(raw) request to my service. This is main.ts and this is update-category.dto And finally this is category.service Here is my simple controller when “given categories” logs items, they have _id which frontend sent to api while I didn’t whitelisted that props in
Validate array object – Swagger/NestJS
I am wondering if there’s a way to create a dto to validate array of object? Example array: At the moment I have this, while it works, it isn’t what I am after. Answer Just use ParseArrayPipe: Update your Controller: Ensure to have items and whitelist set. Update your DTO: