Value App Fixes

Daily Standup

Been doing more than documenting of late! But want to remember some things I learned this week…

App Stops Working 101

Recently the live site of my value app stopped working. Everything looked ok, but when I tried to add a new use to various things, it wouldn’t save the date to the database. The error I got was something like this:

mongo error: MongoError: Unknown modifier: $pushAll

I looked into all kinds of possible solutions for the app’s logic in order to replace the push method with something else, to add new dates into the uses array. I brought the problem with me to Codebar and got some really great advice: before changing any of the code, first update all the npm packages. The logic is that any updates (in this case, to the version of MongoDB that mLab runs for my database server) may have been addressed by package developers, which will make your code work again. And in this case, it worked!

I ran npm outdated in the project folder and learned that quite a few of the packages had updates available:

$ npm outdated
Package Current Wanted Latest Location
body-parser 1.18.2 1.18.3 1.18.3 value-app
connect-mongo 2.0.0 2.0.1 2.0.1 value-app
dotenv 4.0.0 4.0.0 6.0.0 value-app
ejs 2.5.7 2.6.1 2.6.1 value-app
express 4.16.2 4.16.3 4.16.3 value-app
express-sanitizer 1.0.2 1.0.4 1.0.4 value-app
method-override 2.3.10 2.3.10 3.0.0 value-app
moment 2.19.4 2.22.2 2.22.2 value-app
mongoose 4.13.7 4.13.17 5.2.13 value-app
passport-local-mongoose 4.4.0 4.5.0 5.0.1 value-app

So I went through and updated the packages one by one (to know exactly what to fix, in the event any single package had breaking changes). Most of them had minor updates only, but mongoose and passport-local-mongoose needed a major version update, so it was especially important to go package by package.

Thankfully not one of the packages ended up breaking the app on update. And even better, just updating the packages made my app work again! So now I can track the cost per use of the gym membership I bought a couple months ago and yeah…I need to keep going there 😋

Other Stuff

I’m feeling very inspired to develop the app further so that using it can be a little bit easier. Actual action TBD!

My coach at Codebar also recommended a good way to add some testing into the app. Since it’s pretty much already built, it doesn’t seem there’s much sense in retroactively adding unit tests, but as an alternative he recommended Cypress, a framework for end-to-end testing. That means that instead of testing individual functions, it runs tests against the user experience, i.e. if the user clicks X button, does YZ happen? We took a very brief look during the session and I’m looking forward to learning more about this and implementing it in the site.

Up Next

I’ve been thinking about the theatre project I came up with nearly 2 years ago but never started. Think I will make a stab at building out the database and API for that. Will be a great tool to test out serverless functions and React!