Randomness
in Code
Playwright Tests using GitHub Actions + Vercel
March 5, 2024

For a recent project, I wrote some Playwright end to end (e2e) tests which require a running web app connected to a database that contains seed data. This works fine locally, but I wanted to include it as part of the GitHub pull request checks. This meant we would need the app running somewhere externally with an accessible database. Once that exists, we need a GitHub Action to run the e2e tests against that application.Vercel:...

Seeding Prisma Databases in Next.js
February 12, 2024

While developing applications, it's useful to be able to seed the database for a few reasons: The most obvious being that you have actual data to interact with in the UI, APIs, etc. But even if you were to manually create that data, sometimes the data is tampered with or even ruined while developing features. So having a way to reliably and repeatably seed (and re-seed!) the database becomes as valuable as having good test...

Testing APIs in Next.js
February 2, 2024

The latest version of Next.js (which uses the App Router) allows developers to define APIs using Route Handlers. APIs are then defined by the location of the route.js file (which defines the URL) and the exported function (which defines the HTTP method: GET, POST, etc). Documentation exists for creating the routes, but how to test those routes is left to the user.In previous Next.js iterations, I had used node-mocks-http. But...

Yarn Modern (2+) and GitHub Actions
January 29, 2024

I've really enjoyed using GitHub Actions as a method to run CI for my projects. The integration with GitHub is fairly smooth, and once you get it setup, incorporating rules to prevent PR merges without green builds is pretty easy. This has all worked well up until I needed to upgrade Yarn (for reasons to do with Storybook). The process was fairly straightforward, but there were some issues getting GitHub Actions to play...

Using shadcn/ui for components
January 19, 2024

Building apps without a Designer can lead to some pretty poor looking screens (read: Designers are hugely important!). But when working solo, I've often wanted a set of core components that I could use while building out the application logic. I was introduced to shadcn/ui, and find it quite valuable.Not a Component LibrarySo technically shadcn/ui is not a component library. But it kinda is. The trick is you "install" the...

Been a While...
January 1, 2024

Well, hello there 👋 It's been a while since I last made a post. Many years in fact... It's funny, it's been so long that the original code that serves this blog was written using Node 6! Considering the fact that we're on Node 20 now, it's amazing that it still actually works! I'm still writing code and coming across interesting problems, so I thought I'd continue to document those solutions here. Mainly for my own history of...

Universal / Isomorphic Web App
April 15, 2017

I've been working in the world of client side applications for a while now and have really enjoyed using React and Redux. Together their simplicity has allowed me to code in a very deterministic fashion, knowing that if my unit tests pass the page will render. Though working solely in the client has some limitations, and since we own the server it feels a waste to not take advantage of it when rendering pages. The most apparent...

Components, Containers, and Test Apps
June 5, 2016

Web components aren't exactly new, but their use is becoming more widely accepted. We're no longer building pages with controllers and views that mix and match assets together, but rather seeing reusable components that separate pages share. Web developers are now being trained to draw boxes around parts of a page to build a sort of "Russian Doll" set of components. The idea of a component library for a suite of web...

Testing Node on the Server and Angular on the Client
January 28, 2015

One of the most useful features of Angular, in my opinion, is the focus on testing your code. Structuring your apps to use dependency injection by default, along with an out-of-the-box solution for unit and integration tests, gives anyone a great head start in testing their client code. Using a similar solution on the server side, and wiring it all together with a tool like Grunt, provides you with complete testing of your web...

Bundling Production Assets for MEAN.JS
November 19, 2014

Lately, I've been writing a lot of Angular on the client side and Node on the server side. More specifically, I've been using the MEAN.JS template in projects I create, which helps layout a structure to organize the code. Yes, there's a lot of bloat that comes with some of these template projects (and especially with the generators), but once it's all cleaned up and tailored to your project, I think it works very well.One of the...

Creating a Private npm Registry with Sinopia
May 10, 2014

Those who use Node.js at work will sooner or later run into the issue of internal packages. Yes, you could keep all your internal code within a single project, or yes, you could reference your dependencies as GitHub repos in the package.json file, but neither are very elegant solutions. Recommended alternatives for this include cloning the entire npm repository, or using a proxy, similar to that of npm-delegate or Kappa. In...

Authenticated Model: A Strategy for Secure APIs in Backbone.js
February 13, 2014

As I've been using Backbone more and more to create web applications, I've found the need for a security pattern increasingly important. Early on perhaps most of your server side APIs are unsecure, requiring no sort of authentication to access the resources that they expose. But certainly there will be a set of resources at some point which require a layer of security to ensure that not just anyone can access, modify, or delete...

Multivariate (A/B) Testing
December 9, 2013

In web application development, testing the source code to verify it correctly produces the features required is a common practice. Developers will often write tests to validate that the code written satisfies the requirement originally set during the initial design of the feature. This same mindset should exist not just during development, but early in the design of the web application itself, to verify the product is something...

Using Spring to Model Data and Build REST Endpoints, with XML-less Configuration
September 23, 2013

Web applications have been built for years, and Java has often been a top choice as a technology platform. However, the act of using Java to build a web application can feel quite laborious at times with all the duplication and excessive configuration necessary to stand one up. Java EE hasn't had the best reputation for an easily understood web platform, and it's because of this that outside frameworks have emerged attempting to...

Java Logging: Creating, Indexing, and Monitoring
August 27, 2013

Most everyone who has developed an application is familiar with logging. Creating log messages to debug potential problems of the future is a great way to make your life easier. Figuring out how to effectively handle an ever-increasing log file, and more importantly, know when your customers encounter problems through those logs is a more difficult issue. As a developer, monitoring your application can be something that does...

Minify Assets using Grunt
August 13, 2013

Development of any project naturally leads to more and more code as you increase the capabilities of your application. On the server side, this leads to larger compile/build times, and a larger deliverable to servers which host your code. But the difference between a 1MB deliverable and a 100MB...

JavaScript UI Testing with Zombie.js
July 26, 2013

Unit tests can be great to verify your source code, but there are times when integration tests provide a more useful report on the stability of your application. Yes, integration tests (most likely) require more setup than unit tests, and yes, they will (again, most likely) test things outside of the code...

Continuous Integration with Jenkins and Node.js
June 21, 2013

A while ago, I wrote about how you can use Travis-CI for your open source project. And while that works great for open source projects, it's not nearly as free for private repositories as it is for public ones. So if you have a private GitHub repo, or are using GitHub enterprise at a company, what are...

Socket.IO
May 26, 2013

Moving logic from the server to the client is becoming more and more common. But as more moves, the difficulty of keeping everything in sync increases. Providing REST endpoints on the server side for the clients to consume is a great pattern, however that's more of a pull model than a push model. If...

Backbone Revisited
April 19, 2013

In the Fall of last year, I picked up Backbone.js with the hopes of writing a couple front end applications to better understand how it worked. The amount of differences between the client side MVC frameworks and those on the server side turned out to be enough to make me step back, and choose a entry...

Node Version Manager (NVM)
April 13, 2013

Node.js has a great package manager to manage the dependencies of your Node projects, but what about managing the versions of Node itself? Ruby has a version manager called RVM that most folks in the community know to use right from the start. I've installed Node, like most others, using the default...

Hot Embers? First Take at Ember.js (ember-counter)
March 27, 2013

I've been keeping track of Ember.js for a while now, and from what the creators have been saying about the technology, it's hard not to if its truly going to be as good of a solution as they've claimed. Right out of the gate, Ember stresses its a full "top-to-bottom" solution that will address all the...

Using Travis Continuous Integration for your Open Source project
March 21, 2013

I'm a big fan of Continuous Integration in software projects. My background in Java introduced me to this early on with Hudson (now Jenkins), a great tool to build your Maven based Java project, run your unit tests, and publish your build to the Maven repo. Browsing GitHub projects, I've seen tons of...

less-middleware: using LESS with node.js
March 16, 2013

LESS is a great way to write CSS, allowing you to use variables, nested rules, mixins, and many other useful features. If nothing else, I think it helps you better organize your CSS. Recently I've been playing around with Node.js, and wanted to use the less-middleware package so that I could easily use...

Two Tech Stacks, Two Backbone Apps
March 9, 2013

I've recently come across two well written blog posts from two separate companies detailing their technology stacks. Working at a technology company myself, I find these articles fascinating, because they outline decisions and tradeoffs they've had to make along the way. What's fun is finding some that...

Debugging Node
March 6, 2013

A debugger for me, is a necessity. Going back to the days of print statements to debug seems like something I never want to do. And with debuggers coming a dime a dozen in the Java world, this is really something we must have if switching to run JavaScript on the server. Chrome's debugger is certainly...

reveal.js - HTML Presentations
February 20, 2013

A few of my coworkers have recently shown me reveal.js, and it's quite amazing. If you have to make a presentation, the first thing everyone thinks is PowerPoint. But if we're working in the web why don't we make presentations on the web? That's where reveal.js comes in, and every time I see a...

GitHub Pages + JavaScript = Awesome
February 2, 2013

One of the coolest things I've learned of recently is GitHub Pages. GitHub hosts most of the world's code by now, and could just sit back and do nothing, but they constantly keep updating and improving things (have you looked at Gists recently?). With GitHub Pages, anything you put in your "gh-pages"...

My introduction to Backbone.js (backbone-counter)
January 10, 2013

My background is on the server side of things, but recently I've been heavily involved in the client side. And one of the main players in that realm is Backbone.js. For those who don't know, Backbone attempts to serve as a client side MVC framework but really I believe is more of a library than a...