Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Express Route File - Probably writing too much code

I just finished the Express course, loved it. So I decided to make my own blog with Express. What I find is that I am writing a lot of code in my route file. I am defining variables from my JSON file, writing functions to work with the JSON data. As a result, I have a lot of code in my route file before I even get to my routes.

I also found I was doing the same thing when I was using the PHP Slim framework. I dont really have a handle on MVC, but I am guessing the code that is preparing the database data to be passed into a view should be going in either a controller or a modal?