Skip to content

Converting a Node Project from CommonJS to ESM

I had a small JavaScript project (deployed via AWS lambda, which I’ll write about later on). I needed to add a very simple package to the project—detect-cloudflare—which sent me down a deep rabbit hole: My project was written years ago using CommonJS (i.e. require). cloudflare-detect included a bunch of packages for a very simple task, which bothers me. Plus, the IP address ranges were out of date and the package hadn’t been updated in years, I decided I wanted to update it. Should be easy, right? (this is never a good thing for an engineer to say) I updated the project and got all of the tests passing without too much effort. Nice! When I went to use the newly refactored package in my project it failed with this error. Uh oh…

Continue Reading

Deploying Nodejs on AWS Lambda using NodejsFunction

I wanted to deploy a node lambda on AWS using CDK. The NodejsFunction seemed like an improvement over using the standard Function construct: the CDK SDK would bundle your code for you, in a docker container running the same version of node used in the lambda. Instead of defining a code param you define an entry file that is used for the compilation process. This seems like a great improvement over copy/pasting your local nodejs application (including the local node_modules!) into the lambda…

Continue Reading

Learning TypeScript by Migrating Mint Transactions

Years ago, I built a chrome extension to import transactions into Mint. Mint hasn’t been updated in nearly a decade at this point, and once it stopped connecting to my bank for over two months I decided to call it quits and switch to LunchMoney which is improved frequently and has a lot of neat developer-focused features. However, I had years of historical data in Mint and I didn’t want to lose it when I transitioned. Luckily, Mint allows you to export all of your transaction data as a CSV and LunchMoney has an API. I’ve spent some time brushing up on my JavaScript knowledge in the past, and have since used Flow (a TypeScript competitor) in my work, but I’ve heard great things about TypeScript and wanted to see how it compared…

Continue Reading

Building a SouthWest Price Monitor and Learning Server Side JavaScript

I originally wrote a draft of this post in early 2019. I’m spending some time learning TypeScript, so I wanted to finally get my JavaScript-related posts out of draft. Some notes and learnings here are out of date. Both sides of our family live out of state. Over the last couple years, we’ve turned them on to credit card hacking to make visiting cheap (free). SouthWest has some awesome point bonuses on credit cards, but you can’t watch for price drops on Kayak and other flight aggregators. After a bit of digging, I found a basic version of a tool to do just this. It’s a self-hosted bot to watch for flight cost drops so you can book (or rebook for free)…

Continue Reading