thiagobustamante / typescript-rest

This is a lightweight annotation-based expressjs extension for typescript.
MIT License
523 stars 110 forks source link

ContextRequest doesn't have right types #153

Open Paradoxu opened 3 years ago

Paradoxu commented 3 years ago

When accessing the data directly from the ContextRequest, it is returning me a json with the wrong data types, example:

@Path("person")
export class PersonService {
    @GET
    @Path(':id')
    public getPerson(@ContextRequest req: express.Request) {
        console.log(req.query); // { id: "321" }
        console.log(req.params); // { id: "123" }
    }
}

But when I get them using @QueryParam or @PathParam they have the right type which is number, why is that happening? I like the idea of having decorators for getting specific parameters, but it would be nice to have one like @Query, that would return the object received on the query from express, I may have too many arguments on the query, and it's not pretty to get each of them using @QueryParam.

Example of request that generate this: http://localhost/person/123?id=321

Version used: 3.0.2

thiagobustamante commented 3 years ago

it would be nice to have one like @Query, that would return the object received on the query from express

I think it is a great feature. We could include this in a future version