You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the @TypedBody() decorator, it appears that it's not properly transforming the incoming request body into an instance of the given Request class.
Steps to reproduce
Define a route handler method in a controller and use the @TypedBody() decorator to inject the request body, which should be an instance of a certain class (e.g., Request).
Define a class with a method (e.g., getTest), and try to call this method on the request body in the route handler method.
Send a request to the route.
import { Controller, Post } from '@nestjs/common';
import { TypedBody } from '@nestia/core';
class Request {
getTest() {
return 'request';
}
}
@Controller('tests')
export class PostTestAction {
@Post()
async execute(@TypedBody() request: Request): Promise<void> {
console.log(request.getTest());
}
}
See error: "TypeError: request.getTest is not a function"
Expected behavior
The @TypedBody() decorator should correctly convert the incoming request body into an instance of the Request class. The method (e.g., getTest) defined in the Request class should then be callable on the request object in the route handler.
Additional context
This issue is critical as it prevents proper type validation and transformation of the incoming request body, a common requirement in type-safe server-side applications.
The text was updated successfully, but these errors were encountered:
Current nestia does not performan class conversion, and recommends to use pure interface type instead.
If nestia try to support class conversion, it may possible to convert the top level object, because the instance would be imported in the controller class. However, children instances are not. It is hard to compile them, because finding source of children class files are not easy thing.
Therefore, if you want such feature, I'll try but cannot sure of its success. If you want to keep going, would be write an issue in the typia repo? Also, think proper function name please.
Bug Report
When using the @TypedBody() decorator, it appears that it's not properly transforming the incoming request body into an instance of the given Request class.
Steps to reproduce
Define a route handler method in a controller and use the @TypedBody() decorator to inject the request body, which should be an instance of a certain class (e.g., Request).
Define a class with a method (e.g., getTest), and try to call this method on the request body in the route handler method.
Send a request to the route.
See error: "TypeError: request.getTest is not a function"
Expected behavior
The @TypedBody() decorator should correctly convert the incoming request body into an instance of the Request class. The method (e.g., getTest) defined in the Request class should then be callable on the request object in the route handler.
Additional context
This issue is critical as it prevents proper type validation and transformation of the incoming request body, a common requirement in type-safe server-side applications.
The text was updated successfully, but these errors were encountered: