I’m trying to validate nested objects using class-validator and NestJS. I’ve already tried following this thread by using the @Type decorator from class-transform and didn’t have any luck. This what I have: DTO: I’m also using built-in nestjs validation pipe, this is my bootstrap: It’s working fine for other properties, the array of objects is the only one not working.
Tag: nestjs
Nest.js – request entity too large PayloadTooLargeError: request entity too large
I’m trying to save a JSON into a Nest.js server but the server crash when I try to do it, and this is the issue that I’m seeing on the console.log: [Nest] 1976 – 2018-10-12 09:52:04 [ExceptionsHandler] request entity too large PayloadTooLargeError: request entity too large One thing is the size of the JSON request is 1095922 bytes, Does any
NestJs async httpService call
How can I use Async/Await on HttpService using NestJs? The below code doesn`t works: Answer The HttpModule uses Observable not Promise which doesn’t work with async/await. All HttpService methods return Observable<AxiosResponse<T>>. So you can either transform it to a Promise and then use await when calling it or just return the Observable and let the caller handle it. Note that
FileInterceptor doesn’t work
What am I doing wrong? file is undefined Answer The code works as expected in a fresh project. Hence, the dependencies are corrupt. Deleting the node_modules folder and running npm install solves the problem.
Decorator to return a 404 in a Nest controller
I’m working on a backend using NestJS, (which is amazing btw). I have a ‘standard get a single instance of an entity situation’ similar to this example below. This is incredibly simple and works – however, if the user does not exist, the service returns undefined and the controller returns a 200 status code and an empty response. In order