When building an with , Express and MongoDB you can choose Mongoose as your ODM. Mongoose helps you to easily do CRUD operations. When your API grows, usually the amount of models grow and therefore also the amount of express routes grow. In a lot of cases those routes just do simple create, read, update or delete operations. If those routes do not contain any other logic it would be nice if we can just forward the request to a reusable shared function which takes care of the request, right? API Node by on Matteo Catanese unsplash well, yes! Abstracting easy logic can help speed up the development process, increase maintainability and also reduce potential errors or bugs. Let’s assume we’re making an application which let you and your colleagues manage their lunch orders. To get one order, the route could look like this if we would write out all the logic: GET This on it self is fine. But apart from this route would be the same if we would create a route for getting a specific item that you can order for lunch and also if we would create a route to retrieve a specific user. Writing out this code every time for each route would work, but is not really maintainable. One way to solve this, is to move this logic to a higher level in the application, abstract it a bit and then make it importable for every route that requires the above logic. The abstracted logic can potentially look like this: model.Order GET GET GET Now that we have abstracted the logic we can use this in our route like this: GET we pass along the , , and and the function takes care of the rest. By exposing this function we will speed up development for the next route that needs a simple and we increased our maintainability as the logic is only in one place. request response next model.Order get GET Now of course there are more common operations. Let’s look into for creating a new resource. The route for a operation can look like this: POST POST Let’s abstract it again: and use it like this: We can then do the same with as well. Since i think you’re getting the point now. Here’s the full rest.js file for , , and : UPDATE CREATE UPDATE GET DELETE Conclusion We created a rest.js file with reusable helper functions that can take care of common logic. You can extend/change this file to your liking and incorporate things like populates or query paramaters. Happy coding! Thanks for reading. Please hit the clap button if you liked this article. Any feedback? Let me know. Also check my other articles: https://hackernoon.com/validating-reactive-forms-with-default-and-custom-form-field-validators-in-angular-5586dc51c4ae https://hackernoon.com/manage-your-observable-subscriptions-in-angular-with-help-of-rx-js-f574b590a5cb https://hackernoon.com/understanding-creating-and-subscribing-to-observables-in-angular-426dbf0b04a3 https://hackernoon.com/managing-large-s-css-projects-using-the-inverted-triangle-architecture-3c03e4b1e6df https://hackernoon.com/understanding-map-filter-and-reduce-in-javascript-5df1c7eee464 Follow me on Medium or twitter and let’s connect on LinkedIn