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

Michael Collins
Michael Collins
8,925 Points

Are there any videos on Tree house with best practices to limit page access in a DRY way. I am developing in JavaScript?

I am using conditional statements to lock down my pages but find I need to duplicate code on both the front-end and back-end. I know this is not best practice. As I am coding in JavaScript/Node are there any video or other resources that provide insight on how to limit page access in a DRY way. I am open to reviewing resources in other languages but prefer JavaScript.

Regards. Michael

1 Answer

Steven Parker
Steven Parker
230,231 Points

I'm not sure what you mean by "lock down" your pages, and without seeing any of the code I wouldn't automatically assume that doing something in both the browser and server is necessarily "repeating yourself". There are several cases where this is actually a good practice. For example, data validation in the browser can give the user the most immediate feedback, but it doesn't guard against deliberate misuse or program errors. For that reason it is a "best practice" to also perform the validations at the server.