Been doing more than documenting of late! But want to remember some things I learned this week…
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!
npm outdated in the project folder and learned that quite a few of the packages had updates available:
$ npm outdated
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
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 😋
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.
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!