For context, I am running a REST API built with Node.js. Because of callbacks and some complex DB calls, I have a chain of functions that are async but also unique, so it's tough to reduce redundancy. I came up with the idea to call my own endpoints (different endpoints) from within the code itself so I can reduce redundancy. Is this bad practice?
For instance, I would have:
app.get("/puppies/:id"...) // Simple get by ID endpoint app.post("/puppies"...) // Simple puppy update, but checks an attribute of puppy first by getting by ID
In the post endpoint, it would be nice to simply call the "get" endpoint within the post code, but it feels dirty. Thoughts?