4 ms·
Yah, I had thought about inheritance and super, but without multiple inheritance, it'd be tricky. Basically a lot of my routes do stuff like parameter validati
by pfooti 11y ago
Yah, I had thought about inheritance and super, but without multiple inheritance, it'd be tricky.
Basically a lot of my routes do stuff like parameter validation (I store specific criteria on the model class, but apply them in the route), creating a new object from validated post params, loading from the database, storing to the database, authorizing and authenticating, etc. Then my route definition declares the per route middleware and the specific controller only has to encapsulate route specific business logic.
I could do that just by putting it all in a utils package and calling loadItem(), validate params() etc at the top of each handler, but that feels less elegant.
It may be that I've just been using hapi.js for too long, the modularity and composition in that framewrok.is quite elegant, IMO.