Refactoring and improvements

At this point, the application that we've been building is pretty much complete! Before we iterate anymore on the project and continue to build it out and make it ready for production, we should probably consider some refactoring and/or general improvements. Some areas that I would personally take a look at to refactor and/or rewrite to improve the application's performance and overall sanity are as follows:

  • I might rethink working directly with Models so much within the controllers and instead create a utility that I can wrap a lot of that noise and rely on more basic CRUD calls to my Models and only providing a callback to each. This is most visible in the image controller with like, comment, and remove.
  • Validation! There is literally no validation in the project that we wrote and that's mostly for brevity. In reality, we should have included validation on any input fields a user interfaces with. Validation should be provided both on the frontend via jQuery or plain old vanilla JavaScript as well as on the backend with Node. The validation should protect from users submitting invalid and/or malicious code (that is XSS, or Cross-Site Scripting).
  • User authentication! Right now, our application is open to general public, which means any visitor that comes along can upload images as well as delete them! It would be fairly simple to include a user authentication process within our application. Passport.js is a great third-party module to integrate user authentication into Node.js applications.
  • Instead of attaching images to comments for the purposes of the sidebar (newest comments), we should consider creating a more robust aggregate query using MongoDB to retrieve a hybrid collection of comments that includes the image provided directly from MongoDB.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.97.48