Blog
- Speeding up your React Router server-side-rendered (SSR) app with Hono
If you're running a React Router app in framework mode, you get SSR out of the box and for production it hands you @react-router/serve, a small server built on top of Express. While it does the job, Express carries a bit of history (and weight) with it, so if you're the kind of person who wants a leaner server, or just more control over what happens around your app, there's a really nice alternative that drops in with almost no glue.
- Reducing Cognito machine-to-machine (M2M) token costs
Cognito's machine-to-machine authentication is just the OAuth 2.0 Client Credentials flow. To use it, your service hands Cognito a client ID and a client secret, and it gets back a short-lived access token. It's all pretty handy and every successful token request costs you almost nothing. However, when you have a fleet of services asking for a brand-new token on every single call, you're suddenly paying AWS just to hand you a fresh token a few million times when you already have a valid one. Thank goodness that with a few small changes most of those requests simply disappear.
- Improving HTML code blocks readability with a syntax highlighter
A code block written by hand is pretty simple: use the 'pre' and 'code' HTML elements and the browser gives you a monospace font and keeps your line breaks, but it stops there. So every keyword, string, comment and variable comes out in the exact same color, which is fine for a few lines of YAML, but for a few hundred lines of TypeScript painted in a single flat tone, maybe not. Improving readability for those cases doesn't require shipping a highlighting library to the reader's browser (unless you want to) and is quite simple to do.
- Ensuring type safe database queries and migrations with Node
Talking to a database with Node usually goes one of two ways: you write raw SQL and trust that the strings in your code still match the columns in the database, while dealing with SQL injections and migrations by yourself, or you pull in a full ORM and inherit an entire opinionated world just to run simple queries. Both work fine until someone renames a column and you find out about it in production, or you want to do something slightly different and your ORM just won't let you. Fortunately, there's a middle ground where you can get the best of both worlds.
- Creating customizable and reusable project templates with Node
At some point in your life you end up with a repo that is the starting point. It has the CI pipeline you like, your preferred linting and formatting configs and the Terraform layout that works like a charm. Then a new project shows up, you clone the base template and spend the next twenty minutes doing find-and-replace on the project name, ids, the domain name and whatever else is hardcoded in there. It works, until you miss a thing and find out your project is failing - but is it because of the template or because you missed something!? However, a small script and two npm packages solve this problem pretty well.
Powered by Simple Blog API