I am writing quite a large express app at the moment and have had a bit of problem with structuring it. I have now fell in to place by each file containing one and only one path. In it I create a router, add all my methods and logic and export it. For base url files I then import it and do router.use. I was wondering if this is efficient as I have ~30 unique routes that I am one by one having to create a router for, does this have a performance impact or does it affect the speed it takes to match the route.I have also created a special middleware known as loggedIn which checks if a passport user is null and if it is sends a redirect or error message based on method and content-type. I have found this really useful and I was wondering what other application specific middleware everybody’s writing.I also decided to write the controllers alongside the pages. But as I implement the REST side more I am realising that the nice ejs template to controller pairs are getting too busy so I might move the controllers separately.
Submitted November 11, 2019 at 09:15AM by alpha-201
No comments:
Post a Comment