Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Andrew YoungCourses Plus Student 639 Points
Combine route script file into main script
I want to combine the API route and main script file into one file (I now this is not a good way). if I'm combining them how to do it? should I copy the whole file and define as a function and also do I still need to export?
Tom Geraghty24,162 Points
Why? But since you asked...
In your routes.js file, delete the line that has
module.exports = ... then copy and paste the remaining code into your main (root folder) app.js file just below the import statements at the top.
Then remove all of the duplicate and (now) unnecessary imports at the top of app.js (including the import of Routes since you just put Routes into the main app.js file).
But again, why?