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 within the controllers so much, and instead create a utility that I can wrap a lot of that noise in, and rely on more basic CRUD calls to my models and provide only a callback to each. This is most visible in the image controller, with like, comment, and remove.
  • 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 on both the frontend via jQuery or plain old vanilla JavaScript and on the backend with Node. The validation should protect users from submitting invalid and/or malicious code (that is, XSS or Cross-Site Scripting).
  • Right now, our application is open to the 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 (the 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
3.139.97.202