Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Related Rants
So I'm new to NestJS, Node, etc. and I just noticed that the guy working on the API made every request call a different service class, instead of using a single service class. For example.
get() {
return await this.getObj.run()
}
post(myDto){
return await this.storeObj.run()
}
update(myDtoUpdate){
return await this.updateObj.run()
}
And I'm not sure why. He's also injecting the request into those classes, instead of passing the DTO to the method call. I mean, it's still injecting the data into it I guess, but it seems so roundabout. Something like this:
public constructor(
@Inject(REQUEST) private request: Request,
){}
I'm scared, but I'm not sure if it's just my own ignorance or a sixth sense telling me that this is gonna be a mess.
Have you seen APIs implemented this way? I can see the benefit of dividing the code into smaller classes, but it just seems overkill to me, specially when there's a big chance that code will be repeated (getting an entity by ID when updating it, for example).
I'm still in time to kill this with fire before a new monster is born though, so that's something.
question
js
nestjs