This may very well be the most self-annoying, sour post I will write this year.

About me (important to read — will help later)

I am the product of a upper-middle class family (step-father and biological-mother), sexually divided responsibilities (motherly responsibilities vs. fatherly responsibilities), one incredibly logical-based biological-father, and four divorces.

I’m an incredibly abrasive and straight-forward person — I will tell you exactly what I’m thinking with little regard for your feelings if I think it’s important for you to hear.

Simply put, I never sugar-coat.

The case study

I launched Squash Tomato on Nov. 1st, 2017, with great intentions. I wanted to alleviate mothers’ responsibilities to do the grocery shopping…


  1. A user reported some issue with the way labels were working on input fields — essentially, I wasn’t listening for the right events for users to tab through inputs, so I updated it with the following code:
  2. In Safari, and sometimes Firefox, the top label of any form wouldn’t rise on load even though the input’s html tag had “autofocus” set. I found out that autofocus works like this: on desktop, autofocus fires a focus event and sets focus AND the cursor in the designated input field; however, on mobile, autofocus ONLY sets the cursor in the designated input field and doesn’t fire a focus event, because triggering a mobile device’s keyboard is a strict rule that literally cannot be broken. Therefore, If I removed the autofocus from the html inputs, I then had a consistent experience across all devices and browsers.
#1 Code solution

  1. Fixed bug — on email login, the email input wasn’t being lower cased, which would cause an error — “user doesn’t exist” — when you register with your email, it stores it all lower cased. You’d essentially be logging in with an email that doesn’t exist if it had capitals.
Code fixing #1

Been working early mornings instead of nights and I went to Nodevember, so I missed a few days of work due to that (I did some work, but nothing worth making a post over.

  1. Pushed an update that keeps the $$$ total in view at all times and quantity and value inputs are a little easier to input values (can hit ‘Enter’ instead of clicking out of the input).
  2. Fixed a bug where deleting items in random order would prevent you from removing, at least, the last item in your list. Let me explain:

Investigated and found:

If I deleted…


Using Mongo, Express, Pug, and Node.js (with a bit of Socket.io)

Tip for you: saying you’re working on “permissions” doesn’t give anyone a fucking clue what you’re really doing. Trust me, I know from experience 😐.

If you’re new to permissions and looking to get a quick understanding of the main types of permissions in 5 minutes, this is for you.

Permissions

I can think of two types of permissions relating to software: authentication and user roles.

Authentication

Do you have the rights to access this?

Essentially, authentication permissions are login permissions and access permissions:

  • Login permissions questions whether a user has registered and is/not logged in.
  • Access permissions asks does the user…

  1. Commented out all list controller and client-side code.
  2. Was worried about checking for permissions on each list controller method, which could run 100x before a reload (methods handle API request to do things such as add items to a list, update the total, and delete an item), and decided to create a global variable. This variable would be declared as null, but on each API call, the respected list controller method returns the permission variable and sets the global variable using the return permission variable.
  3. Modified the list controller add method (handles an API call by the client-side add function)…

  1. Working on what I’m now calling, “The Permission Pass.”
  2. Debugging a controller running 4 times for a route (/my-lists/:username/:list) — didn’t figure it out, but it relates to the :keys in the route. Each :key is responsible for 2 controller executions… Thought it best to continue with development and come back to it later.
  3. Built a new API route to handle getting user permissions.
  4. Got super pissed at my sisters and mom, because I complained about getting up to let them in the house when both my sisters had keys in their pockets. In return, my sister told me, “it’s…

  1. Refactored all my client-side JavaScript functions to be pure.
  2. Added list functionality to my Squash Tomato documentation.
  3. Removed the /home route from the site, which took users to their list.
  4. Added route functionality for /my-lists, which finds all list a user is related to, whether the owner or just a member of a list, adds a list.url and list.name if one didn’t exist (explained below), and renders all the found lists as cards.
  5. Updated all User model documents in the ‘user’ collection: copied the user.email, user.name, and user.list to a new collection, ‘lists’. Since the User model didn’t have the…

  1. Began writing a blog post on how to use Socket.io in a MVC app.
  2. Worked with a few friends who had experience with WebSockets.
  3. Started to realize that my backend logic for Squash Tomato wouldn’t be able to handle the features I wanted to build, so I’m rewriting my backend logic and I’ll make it public (you’re going to see quite a bit in this post).
  4. I’m making a document that contains all the details of my app including what X is for and why X is the way it is. The details and flow of my app was becoming…

  1. Organized the future functionality of family lists
  2. Searched for realtime solutions for my user interface. I wanted users of the same list to see the changes another was making as soon as they changed them. I came upon WebSockets. Although I’d like to use the barebones WebSockets’ API, I’m using Socket.io for speed since I’m up against a deadline!
  3. Went through the Socket.io tutorial — Someone is clearly more intelligent than I am 😆
  4. Began to integrate Socket.io into Squash Tomato on a git feature branch (separated from master, which controls what’s running on my server)
const mongoose = require('mongoose');

Chris Johnson

Full-stack Surgeon (Design, Vue, Node, mongoDB), knowledge seeker, world dominator, Harry Potter and anime addict, volleyball player, and unfiltered.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store