Before 2022 closes out, for the first time in written form, I want to take a moment to reflect on the past year and also to look forward. A lot has been accomplished, both personally and professionally. This blog post will mostly serve as motivation for the next year and to hold me accountable. As the years keep flying by, I realize more than ever that I need to maximize my time to get to where I want to be. Let's take a look at the latest of the journey.
Generate Up and Down Migrations for Platformatic DB using Prisma
I've spent the past few days experimenting with Platformatic DB, a new open-source project that can generate REST and GraphQL APIs from your database. Platformatic's goal is to remove all friction for back-end development. After initializing a new project, the first thing you'll have to do is write SQL migrations. I come from a background of using ORMs such as Prisma where migrations are automatically taken care of for you so it's not something I'm used to doing. I also think writing your own migrations introduces risk for user error like forgetting to create a foreign key. So let's take a look at how we can use a Prisma schema to generate up and down migrations!
Automate Onboarding Express Accounts in Stripe Test Mode
While implementing a Stripe Connect integration, I repeatedly came across the tedious task of onboarding Express accounts to test the integration, whether that be manual or automated testing. Creating an Express account using Stripe's API is an easy task, but in order for the account to be verified to accept payments and transfers, the account needs to manually complete onboarding forms on a Stripe hosted page. Let's take a look at how I automated the onboarding process.
TypeScript typings for Stripe Webhook Events
I'm working on a project that relies heavily on Stripe webhooks and while implementing the webhook handler, I noticed the lack of type safety increases the risk of error in my implementation. This could be something simple like misspelling the event name or trying to access the event's data.object
fields incorrectly. For this reason, I built a way to generate typings for all webhook events to strongly type the event object.
Test Stripe Subscription Lifecycle using Test Clocks
Stripe supports many different subscription models such as flat fee, metered billing based on usage, and scheduled subscriptions. In any case, testing your subscription through the course of it's lifecycle is crucial before going live. With the help of Stripe's test clocks feature, this is possible!
Flaky Cypress Tests and Network Requests
There can be many potential causes for flaky Cypress tests and this can be a cause of frustration when it comes to testing. I recently upgraded a project to Cypress 10 and discovered one of the causes for flakiness was due to assertions running prematurely before network requests had completed. I assumed Cypress automagically handled waiting for requests to finish but that's not the case. So let's take a look at how to wait for network requests to finish before your assertions are run.
Angular 14 - Standalone Components, Directives, and Pipes
Angular standalone components! This is a feature that I've been wanting for a while. After reading the RFC last year, it's great to see this feature come to fruition in Angular 14. It's a huge improvement to developer experience because we no longer need NgModule
which reduces a lot of boilerplate, and in turn eliminates common errors that occur like forgetting to declare components.
How to Test Yargs CLI with Jest
Display Recent Blog Posts on Home Page with Docusaurus 2.0.0-beta.16
I've found Docusaurus to be a great tool for both documentation sites as well as blogs because it provides great functionality out of the box and lets you focus on your site's content. I'm in the process of migrating a few sites over to it. A common feature for the sites I'm building is to display a list of recent blog posts on the home page. Unfortunately, there isn't a straight forward path to do this.
Consuming Contentful GraphQL API using Angular
In a previous post, I showed how to integrate Contentful into an Angular project using their REST API. Now that Contentful's GraphQL API is available in the community edition, it should be the preferred way to build your front-end and I'll show you why. This is an example of how to use Contentful to store blog posts, and create a front-end using Angular that will access the data using the GraphQL API.