EntityFromParam decorator error when param value is uuid #22
Labels
status: invalid
Issues with no action to take.
type: question
Questions about the usage of the library.
Summary
This is a bit of a weird one. In short when using a uuid in my request param I am not able to use the EntityFromParam decorator in my controller action for fetching entities.
After digging into this a little bit it appears that this is a result of the implementation in typestack/routing-controllers here: https://github.com/typestack/routing-controllers/blob/master/src/ActionParameterHandler.ts#L136-L139
Since the the param type is an Entity constructor there is no way to prevent
typestack/routing-controllers
from passing the uuid to JSON.parse resulting in an error.There was a related issue here: typestack/routing-controllers#51, but it was closed since they were not using a constructor as the param type.
Steps to Reproduce
@PrimaryGeneratedColumn("uuid")
for idget(@EntityFromParam('id') entity: Entity) {}
http://localhost:3000/entity/:id
where :id is the uuid of the entityError Message
There are a couple of workarounds that I have tested, but they feel less elegant:
Sample Decorator
I apologize that I am creating this bug on here instead of
typestack/routing-controllers
, but it felt like most of the context of the problem was centered around@EntityFromParam
.Also I absolutely love this project! Keep up the amazing work!!!
The text was updated successfully, but these errors were encountered: