Keeping these principles in mind means you’ll know what to do when your requirement go beyond those presented here and in other examples. This ensures your code is flexible and allows it to be recomposed for cron tasks, unit testing, etc. Composing your app in pieces that are isolated and easy to understand. Organizing functions and modules to ensure they have a single, clear task which ensures your code is easy to read and maintain. While there are a variety of recommendations below, they are all based on the same principles: Otherwise, you’ll need to spend considerable time and expense rewriting your application. If you plan to scale your API the decisions you bake in earlier should support that. This means bugs increase and deployments become slower and riskier. Without good structure, it will become increasingly hard to understand your code and easier to accidentally break things. Why does structure matter? Why not use a “move fast and break things” approach and put your code wherever it seems to work? In this post, we’ll consider some best practice approaches to structure a robust and high-performing Express REST API project. This can lead to issues around maintenance and scaling. One of the great things about Express is that it’s a very light and unopinionated framework which makes it extremely flexible in how you set it up.Ī possible downside is that there isn’t much guidance on how to structure applications. So you’ve decided to join thousands of other companies and use Express.js to build a REST API.
0 Comments
Leave a Reply. |