Hi, bit of a newbie here when it comes to best practices!
So I was trying out microservices, and here's the scenario that I have a question about:
I have an API gateway, with a guard applied to one of its controllers
@VerifyThingsAboutRecordGuard("")
@Patch(":id")
doSomethingWithExistingRecord...
Inside the guard, I use the "id" route parameter of the request to fetch the record using the provided id, and do some checks on it.
If it passes all checks, I want to append it to the request, similar in fashion to how passport does with the user (req.user).
Then, in the controller, I'll have a decorator to grab that appended record, and i will pass it along to the service.
The record I pass in is quite a bit more "hefty" than if I would just send over the id of it. And I can't really validate it either - in my DTO it simply looks like this
@IsNotEmpty()
@Type(() => Record)
record!: Record;
If it wasn't clear why I thought it was an issue to send in the recordId instead, it's because, the work to find the record was already done. So if I just passed in the id I'd have to fetch it again.
Are there any pitsfalls here or am I thinking the right way? Is any of the ways bad practice?
Thanks a lot in advance!