Skip to content
Advertisement

Tag: nestjs

NestJs ParseEnumPipe can’t be resolve

I am using the NestJs framework (love it by the way) and I want to check the incoming data so it conforms with an Enum in Typscript. So I have the following: The weird thing is that when I run this code, the first pipe gets compiled What I am doing wrong? Answer You should use @Body(‘action’, new ParseEnumPipe(ProductAction)) action:

GraphQL – “Field “updateOwner” of type “Owner!” must have a selection of subfields. Did you mean “updateOwner { … }”?”

I’m trying to get Mutation Update query in GraphQL Playground. I’m basic level in GraphQL and in learning phase. I don’t know how to create udpate Mutation for the below Owner code. Any idea what I’m missing in my code / query? —Resolver— —Service— —dto— —entity— —schema— —GraphQL Query (I don’t know whether it is correct or wrong) —error— Answer

Filter array object by type and compare key

I have two arrays, in one (aux) I get key and value. In the second array of objects (result) I have the attribute “correlati” and what I’m looking for is that if the key of the array “aux” is equal to the attribute “correlati” then it pushes that result in a new array that looks like the following : code:

How to create dto of an complex object in NestJs

I’m a beginner at NestJs and I want to create a dto of the following struct: I want to create an API that can return this object using DTOs. I tried the following dto but I got an error in the service provider : I create 3 classes OneSessionResponseDto, SessionsResponseDto, and WeekResponseDto so I can use them as a dto

Vulnerability in NestJS 8.4.5

Recently, when I run npm audit in my npm package, I receive the following error: The problem seems to be in the dicer package which is a very popular package used by NestJS. I searched the web for possible solutions but can’t find any fixes. Has anyone been able to fix this yet? Thanks in advance. Answer It seems that

In the next major version, Nest will not allow classes annotated with @Injectable(), @Catch(), and @Controller() decorators

I’m writing in Nest.js framework for 3 years and i got the message in by backend-application: I researched nest.js github and stuck what is the problem and why it says about some deprecation of useable decorators. Does anyone know how to solve this problem or what will be in the next major version of Nest.js framework Thanks in advance! Answer

Error: No “exports” main defined in graphql-upload/package.json

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:

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

Advertisement